querying data via $wpdb and get_row
I am using the Contact Form 7 Plugin to keep data of a form and I would like to query a table to show the results in a template. So this is what my query is:
global $wpdb; $query = "SELECT count(*) as num FROM wp_cf7dbplugin_submits a,wp_cf7dbplugin_submits b WHERE a.field_name = 'Buyer' AND a.field_value = 1 AND a.submit_time = b.submit_time AND b.field_name = carbrand AND b.field_value='Mercedes'"; $results = $wpdb->get_row( $query, OBJECT ); var_dump( $results );
For some reason
var_dump() spits out a
NULL value. When i run the same query in mysql console I see the result that it is supposed to return 2.
Can anyone advise me on what I’m doing wrong? I went over The Codex to integrate
$wpdb variable but I can’t say I was successful…