I hope I can explain this correctly. Here it is:
I have a list of id’s that I need to check in a mysql table against a subscription status to find out how many of those id’s are current. I have the id and the subscriptionEnd. My query is not working and I do not have enough knowledge to know how this would be done. Please review and share with me what I could do. There are thousands of id’s I need to match against.
SELECT c.id, c.subscriptionEnd
FROM subscriptions c
WHERE c.subscriptionEnd > '2013-01-27`
AND c.id = 12345
AND c.id = 12939
....
This list goes on and on and I see that this will not work. But the problem is I don’t know how to get this to work. Very much appreciated with any solutions on how I can check and get the results of the id’s that have a subscriptionEnd greater than the date given.
Thank you
Your best bet, since you have 1000’s of values to check against, is to insert all of the ids you want to check into a temporary table – let’s call the table
checkIdswith a single columnid.Then you can simply do:
And finally drop the temporary table when you are done.
Other solutions include:
A giant unwieldy
INclause which will probably be a performance nightmare:Finding a pattern in your list of IDs: