Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

两个表:文章表-article标签表-tags

文章表的标签字段用来保存标签表的ID,用的是字符串形式来保存,如图:

clipboard.png

clipboard.png

也就是说如果一篇文章的tags含有1,2,这篇文章就属于php相关和js相关

现在有一个 php 标签的id=1,请问怎么从文章表里面把 tags 含有 1 的所有数据查询出来?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
375 views
Welcome To Ask or Share your Answers For Others

1 Answer

select * from article_table where tags like '%,1,%' or tags like '1,%' or tags like '%,1' or tags='1'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...