I’ve been trying to delete rows in a table where NOT IN php array.
basically, the table contains table_1_id, table_2_id, is_active
So my query is :
$delete = "
DELETE FROM pivot
WHERE (table_1_id, table_2_id)
NOT IN (
".implode(',', array_unique($table1Ids)).",
".implode(',', array_unique($table2Ids))."
) AND is_active = 1
";
However, this query deletes all the rows EITHER table_1_id‘s value not in $table1Ids or table_2_id‘s value not in $table12ds.
I expected it to delete rows, STRICTLY to compare both table_1_id and table_2_id at the same time, not EITHER.
Sorry for bad explanation, seems too hard to put into words.