I have the query:
SELECT * FROM `users`
WHERE (`firstname` LIKE 'Luke' AND `lastname` LIKE 'Skywalker') OR
(`firstname` LIKE 'Foo' AND `lastname` LIKE 'Bar') OR
(`firstname` LIKE 'Tom' AND `lastname` LIKE 'Turner');
But i would like to make it a bit more readable by using a where ... in ... I tried
SELECT * FROM users
WHERE `firstname`
IN ('Luke','Foo','Tom') AND `lastname` IN ('Skywalker','Bar','Turner');
But unfortunately this will also match "Tom Skywalker"
, "Foo Turner"
and all mixes you can think off.
I have to select on first and lastname (perhaps more fields like DOB) since i am getting data from an external API and i have to check if those names are in our system.
SELECT *
FROM users
WHERE (firstname, lastname)
IN ( ('Luke', 'Skywalker')
, ('Foo' , 'Bar')
, ('Tom' , 'Turner')
)
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With