Forum Moderators: open
i am having a problem writing a complex query.
I have 800 records in a table.
One field has stored ids from another table.
The ids are in "2,34,11,56,78,45" format.
What is the best way to search these fields for an id sequence?
I mean, if i have the ids 4,6,8,12,45,34 and 1, that i wanna check, how can i do this?
I have try the LIKE syntax but dont work. Whenever i search for id LIKE '%1%' i also get 1,11,21,31,... (which is logical). How can i isolate the 1 only and leave out the 1x (11,12,13...21,31...) ids?
if your looking in a comma seperated string you could do
WHERE LIKE '1,%' OR LIKE '%,1,%' OR LIKE '%,1'
you then have all the options of if the 1 is at the start of the string, in the middle of the string or at the end of the string.
I await a better way to do it ;-)