How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

Just to clarify the get_var() method of $wpdb does work just fine in this context:

global $wpdb;
$helloworld_id = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name="hello-world"");
echo $helloworld_id;

Actually it is more practical in this context, because a single variable is returned, which is what is actually wanted.