How to pull data from a table using wpdb?

First, you want to use the global $wpdb variable.

global $wbdp;

Then set up your query. Make it a separate variable so you can output it and check for syntax errors.

$my_query = $wpdb->prepare( /* SQL query here */ );

Then execute the query.

$results = $wpdb->get_results( $my_query );