How to create custom query by keyword in post title?

Codex has quite an extensive article on this – Displaying Posts Using a Custom Select Query.

In a nutshell:

// retrieve posts using our custom SQL (note that you should query * rather than pick fields)
$posts = $wpdb->get_results($query, OBJECT);

// this is global variable that WP functions rely on for output
global $post;

// loop
foreach($posts as $post) {

    // get global stuff filled current post
    setup_postdata($post);

   // use template tags and profit
   the_title();
}

// cleanup after ourselves
wp_reset_postdata();