Learn how to fetch a single value (e.g., post title) from the database using $wpdb->get_var()
.
global $wpdb;
$post_id = 1; // Replace with the ID of the post you want
$title = $wpdb->get_var($wpdb->prepare("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = %d", $post_id));
echo "Post title: " . $title;