I'm trying to do this:
SELECT * FROM library WHERE $cat IN (tags);
Say that I have $cat = '15';
and tags
is a fieldname in library
that looks like this: 2,15,34, 45
How can I get it to work? I understand that normally the $var should be after the IN ($var), but the imploded array sits in my DB and not in the $var - somehow I've gotten it the wrong way around and I just cannot figure it out - Please help me, I'm wasting days :)
You can use FIND_IN_SET
instead, like this:
SELECT * FROM library
WHERE FIND_IN_SET($cat, tags);
从库中选择*,其中'%,$ cat,%'等标签;
你不会这样做:
SELECT * FROM library WHERE tags = $cat
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.