Reputation: 3950
Table_One
id name groupid
1 AAA 5,6
2 BBB 5,7
3 CCC 15
I am trying to make a query something like:
select * from Table_One
where Table_One.groupid like '%".$objectData[groupid]."%'
such that if value of $objectData[groupid]
is 5 then result should be
1 AAA 5,6
2 BBB 5,7
Similarly, if value of $objectData[groupid]
is 6 then result should be
1 AAA 5,6
and, if value of $objectData[groupid]
is 7 then result should be
2 BBB 5,7
Upvotes: 4
Views: 126
Reputation: 29071
Instead of using LIKE
use FIND_IN_SET function, try this:
SELECT *
FROM Table_One
WHERE FIND_IN_SET(".$objectData[groupid].", Table_One.groupid);
Upvotes: 2