Let's say I have a table, email_phone_notes
that looks like this:
+-----------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+--------------+------+-----+---------+-------+
| email | varchar | NO | PRI | NULL | |
| phone | varchar | NO | PRI | NULL | |
| notes | text | NO | | 0 | |
+-----------------------+--------------+------+-----+---------+-------+
So, each email/phone combination is unique, but you could have several email addresses with different phone numbers and vice versa. This is a little contrived but it mirrors my scenario.
I'd like to do a query like this:
SELECT * FROM email_phone_notes WHERE email = '[email protected]' AND phone = '555-1212';
But, I'd like to do multiple pairs at once so I don't have to make several SELECT
queries. It's also important to keep the pairs together because I don't want to return an errant phone/email combination that wasn't requested.
I could do something like this, but for the possibility of several hundred values the query will be really long.
SELECT * FROM email_phone_notes WHERE (
(email='[email protected]' && phone='555-1212') ||
(email='[email protected]' && phone='888-1212') ||
...
Is there a more elegant solution, or should I stick with this?