You need to use a join in your mysql query.
Something like this might get you closer…
global $wpdb;
$rsvp_table = $wpdb->prefix . 'rsvp';
$invites_table = $wpdb->prefix . 'invites';
$sql="SELECT COUNT(*) as count
FROM $invites_table i1
JOIN $rsvp_table r1 ON (r1.reference = i1.reference)";
$yet_to_respond = $wpdb->get_results( $sql );
echo $yet_to_respond->count;
Related Posts:
- How to use $wpdb to delete in a custom table
- get_results on large datasets
- Is there a (better) way to access $wpdb results?
- Using $wpdb generates DB error
- How do you use prepare when asking for a list of id’s
- how to execute different sql query in non-sanitized $wpdb->get_results function
- WPDB update row with != in where clause
- How to update records using $wpdb?
- Need help writing a $wpdb query
- show badge with count for pending items in custom post type
- WP Sql query multiple where clause
- WordPress SQL query – returning ‘true’ ‘false’ or ‘null’
- Modify the structure of data returned by $wpdb
- Syntax for $wpdb->prepare when searching in two columns
- Confused by $wpdb->prepare
- How to display user_nicename and usermeta values by custom query in WordPress?
- Optimizing WordPress Queries – Removing Group By ID
- How can I combine one field using wpdb and group by?
- $wpdb->prepare with ON DUPLICATE KEY UPDATE
- how to use $wpdb->prepare to update a custom table
- WPDB Placeholders and second argument for prepared statements
- Increment integer field in database when WHERE needs to be dynamic [closed]
- Custom SQL query ORDER BY term_order
- Custom $wpdb returns unexpected time based results
- How to left join meta in queries [closed]
- wpdb->get_row is selecting the variable as a column name
- CREATE TABLE with dbDelta does not create table
- $wpdb query outputs php code instead of executing it
- wpdb query not working
- WordPress wpdb->insert returns int(0) => doesn’t insert anything, no errors!
- WPDB SQL Ignore `post_status` Parameter
- how to list all post that are in the custom taxonomy using $wpdb
- WPDB SQL query SELECT from category
- How to use WHERE NOT EXISTS query to avoid duplicate entry using $wpdb to save in custom table?
- Creating an Angular factory from custom database table
- wpdb->update update the entire table instead of one row
- How do I update post based on meta_key in another table?
- How to set up prepared query using IN statement
- Custom database query to validate data
- Alter the main search query to search posts by coauthor user name
- Creates only one table and not the other
- Protect custom form from SQL injection
- looking for a way to allow users to backup the plugin db data(save as)
- SQL Query to select post title & post ID from a particular category
- Get comments after specific date
- query using wpdb in wordpress gets me no result
- query_vars doesn’t return query string (trying to get data from $wpdb)
- wpdb->insert: do I need to prepare against SQL injection?
- How do I check for a duplicate record before inserting using wpdb
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- Avoiding “Usage of a direct database call is discouraged”
- passing variables as parameters to stored procedures via wpdb from php-script
- How Can I Use $wpdb in PayPal IPN file?
- $wpdb->query() multiple query support
- $wpdb Query Result not coming but in phpmyadmin it works [closed]
- How to email user after inserting the username in database in WordPress
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Join inside a wpdb query.. confused!
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Why doesn’t my insert query work?
- How to prevent $wpdb->prepare stripping a leading zero in variable value?
- Generate a unique hash/number for tracking on $wpdb insert
- wpdb->insert and stripslashes against sql injection
- $wpdb select query by month, post type, and taxonomy term
- WPDB – How to search a column in a table
- How to access PostgreSQL using WPDB?
- $wpdb not being defined in function: Fatal error: Call to a member function query() on a non-object
- How to obtain a reference to $table_prefix in $wpdb object
- Trying to Connect to different database
- Why does this WPDB code throw an empty WPDB error? [closed]
- wordpress $wpdb works only once
- get_results not returning anything
- WordPress core code contains things marked as deprecated by… WordPress?
- $wpdb – joining shows no result
- Compare transient data with a meta box value
- Sql formatting for post data within function
- Get unique results from this function
- prepare function sql safe method
- WPDB Table Does Not Exist
- Inserting a MySQL record into a table with an array of field names and an array of values
- Incorrect Use of wpdb::prepare()
- Ascending order of yearly archives [closed]
- $wpdb->get_results(…) with $wpdb->prepare(…) returns empty array despite correct query
- wpdb insert formatting for date in array
- Passing a SQL query to the WP Query
- Access to numerically indexed array in wpdb Class and undefined offset
- $wpbd->insert() does not insert user data
- Why $wpdb->insert and $wpdb->update not working server but it is working in localhost?
- wpdb prepare placeholders for MySQL keywords
- Sql query triggered twice
- Unable to insert data into using custom plugin
- Debugging db calls: $wpdb->insert works on test site, not on identical production site
- Fastest and most efficient SQL query to check if UID exists
- Run an update query in a function
- Object Cache – Avoid db queries totally
- adding a log row log table, when the draft post publish
- Out of Memory – Line 791 of WP-DB.php (mysql_real_escape_string)
- Site going down due to slow queries
- Call to a member function get_results() on a non-object in wordpress plugin
- Can’t send form data to wpdb when URL has query string