简体   繁体   English

mysql命令按逗号分隔字段中的匹配项

[英]mysql order by matches in comma separated field

I have one blog table which contains different tags, 我有一个博客表,其中包含不同的标签,

now i want to order blog by max tag match 现在我想通过最大标签匹配来订购博客

and am storing tags comma separated in one field 并在一个字段中存储逗号分隔的标签

now how to do that? 现在该怎么办?

I tried find in set but still dident get work. 我尝试在集合中查找,但仍然没有得到工作。

Please suggest me any better way to do so. 请建议我任何更好的方法。

table like: 像这样的表:

id | title | desc      | tags

1 | test1 | test1 desc | t1,t2,t3,t4

2 | test2 | test desc  | t1,t2

3 | test3 | test desc  | t1,t2,t3

4 | test4 | test desc  | t3,t4

5 | test5 | test desc  | t1,t2,t3,t4

here suppose i want closest blog post of "test1" post then answer should be 5,3,2,4 这里假设我要“ test1”帖子的最近博客帖子,那么答案应该是5、3、2、4

first match with tags and after that if same tag count then by id 首先与标签匹配,然后如果标签计数相同,则按ID匹配

您应该首先将标签分成不同的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM