I can’t seem to get the SQL to work when using LIKE
DELETE FROM `customer_numbers`
WHERE number NOT LIKE (SELECT number FROM number_part)%
Basically delete all the rows from constomer_numbers table if number does not contain in number_part table
Example:
customer_numbers.number = 0559354544 and number_part.number = 05593 – it shouldn’t delete it.. However if 05593 does not contain in customer_numbers.number then delete row from customer_numbers table.. It should match first 5 digits from number_part
You can’t use not like with a list (in most databases, I’m pretty sure this is true in mysql).
Instead, you can use a correlated subquery: