I have a web (intranet) tool that parses a users list into an array of first and last names. I’m then looping through that array (which could be 50 times) like:
SELECT * FROM users WHERE last_name = array[x].last AND first_name = array[x].first
Is it possible to somehow query all those first/last name combinations at the same time like an IN statement with two properties.
What I’d love if it was possible is a single query that returned a record set of every match that was found (I guess like an IN statement w/ 2 properties). I’m not that great with MySQL but my guess would be this would be something like having a sub-query gather a list of any first name matches and then another sub-query gathering any last name matches.
You know actually if I just made there query as where first_name IN () OR last_name in () I’d have a result set with any possible match and then I could loop through that result set doing a final check for where the first and last names both match. This db is fast, but it’s massive. For example, there are 8,000+ users
Here is a nice trick with MySQL row constructors:
http://sqlfiddle.com/#!2/6ef9a/2
It also works with
IN:http://sqlfiddle.com/#!2/6ef9a/6