I need to insert data except if 2 fields exist in that row. Below is my current query that adds everything that works.
$sql = "INSERT INTO contact_sync_status (ghl_contact_email, ghl_contact_data, result, wp_user_id) VALUES ('$source->email', '$payload', 'success', $user->id)";
So I tried the following to make it conditional:
$sql = "INSERT INTO contact_sync_status (ghl_contact_email, ghl_contact_data, result, wp_user_id) VALUES ('$source->email', '$payload', 'success', $user->id) WHERE NOT EXISTS (SELECT 1 FROM contact_sync_status WHERE ghl_contact_email = '$source->email' AND wp_user_id = $user->id)";
But i receive a SQL syntax error because it seems that WHERE NOT EXISTS can't be used with INSERT. I've also tried a unique index in the DB but this is not an option.