MySQL search in comma list -


I have a MySQL field with reference to another table where the ids are saved as a comma separated list, Such as:

  12,13,14,16   

which stand for value in any other table. I know this is very bad and wrong, but it comes from above and I can not do anything about it Now the problem is that I want to search with this type of query in this area:

  SELECT ... '% 1%' as the WHERE field   

The problem is now clearly that almost all entries can be found with this example because the query Most common ID ranges are in 10-20, instead of searching for% i, 1,%, but this is In Setr first and does not work for the last ID. Is there something like an inner space or how do I fix it?

You need the function: SELECT ... WHERE FIND_IN_SET ('1', field)

Comments