WHERE NOT IN is what you need.
$sql = “INSERT INTO trip_rate (id, trip, rating, r_name, email, title, review)
SELECT ”, ‘$trip’, ‘$rating’, ‘$name’, ‘$email’, ‘$title’, ‘$review’
WHERE (trip_rate.email)
NOT IN (
SELECT email FROM trip_rate WHERE email=”$email” AND trip=’$trip’)”;
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
- 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
- Get count of rows based if column exists in two different tables
- query_vars doesn’t return query string (trying to get data from $wpdb)
- How do I check for a duplicate record before inserting using wpdb
- prepare() not working
- passing variables as parameters to stored procedures via wpdb from php-script
- $wpdb->query() multiple query support
- Set media metadata (i.e. “dimensions” field) on SVG file after extracting it with a filter
- $wpdb Query Result not coming but in phpmyadmin it works [closed]
- 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
- $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
- How to pass orderby params to $wpdb->prepare()?
- 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
- How to get INSERT errors from $wpdb?
- Display category names on edit user profile using $wpdb
- 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
- Include post_status check within $wpdb query
- wpdb get_row database query inquiry
- Depreciated Call -> Function wpdb::escape()
- Inserting and updating rows with wpdb indreases integer fields by 1 point sometimes
- Retrieve a list of users based on some conditions
- wp_commentdata: error in documentation?
- wp-postratings: list current user’s unrated posts
- Error inserting row into table
- get only 1 wpdb and get taxonomy, post to next page [closed]
- $wpdb The query does not contain the correct number of placeholders
- $wpdb:insert, more arguements in $format array than in $data