My table for the categories
table concept_category:
id category_title
-----------------------------
1 category1_title
2 category2_title
3 category3_title
4 category4_title
5 category5_title
and the table with the concepts
table concept:
id catid title
-----------------------------
1 3,5 title concept1
2 5 title concept2
3 2 title_concept3
Now I try to get all the results where the catid is 5. But the result it is giving is only the title_concept 2 and I want both title_concept1 and title_concept2. This is my query
SELECT id, title, catid
FROM concept
WHERE catid = (5)
Im not seeing what im doing wrong.. can somebody help me?
Use FIND_IN_SET()
SELECT id, title, catid
FROM concept
where find_in_set(5, replace(catid, ' ', '')) > 0
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.