
Hi,
if we use
1. like '%1%' --> it checks if any part of string has 1 or not
2. like '1%' --> it checks if the string starts with 1 so here 11,2,1, also comes
3. like '%,1,%' --> ,1, anything.
So, better use like '%,1,%' --> this means only 1. since "," is included to separate.. it takes the whole part (,1,) and it is only 1.
Note: If the string is 12,2,3,1 --> Here ending with 1 so specify a or condition with like '%,1' that means string ending with 1.
In the same way, if starts with 1 like '1,%' or if the string is only 1 then '1'
Totally:
SELECT proid FROM e2 WHERE catid LIKE '%,1,%' OR catid LIKE '1,%' OR catid LIKE '%,1' OR catid = '1' .
I think there might be a more simple query than this.
Regards,
Awesome Coding !! :)
Alok, if this helps please login to Mark As Answer. | Alert Moderator