I have data in comma-separated format such as this.
$theAttachID = "bob@somedomain.com,tom@anotherdomain.com,jill@herdomain.com";
I have a mysql database that contains a users data. There is a field name called "Email" that contains one email address for the user. I want to check the value of "Email" with an sql query to check against the data contained in the variable "$theAttachID". Someone suggested to me to use IN() with my sql query such as this.
Ex.
$sqlquery = "SELECT * FROM Customers WHERE Email IN ($theAttachID)";
But this doesn't work. I suspect that in() only works with numeric values as it will work with numbers but not with email addresses.
Anyway, my question to the community is, how can I efficiently code an sql query that will check the information in variable "$data" against the "Email" field in my database table? Note, the "$data" variable may hold up to several dozen email addresses in it, so finding a way to do this efficiently at query time is important.
Thanks for any suggestions.