Reputation: 15
I have works
table, with columns id
, employer_key
, task_key
, etc. The task_key
column contains task keys such as 122,142,
or just one key 124,
or more.
My problem is when I do the query:
"SELECT * FROM works WHERE 122 IN(task_key)";
The query works only if the 122 is the first number listed, but if I search for 142, the second number listed, I don't get any result. Does anyone know why?
Upvotes: 0
Views: 38
Reputation: 16467
You probably should change your schema but to do what you want you can use FIND_IN_SET()
SELECT *
FROM works
WHERE FIND_IN_SET('122',task_key) > 0
Upvotes: 1