繁体   English   中英

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

[英]mysql order by matches in comma separated field

我有一个博客表,其中包含不同的标签,

现在我想通过最大标签匹配来订购博客

并在一个字段中存储逗号分隔的标签

现在该怎么办?

我尝试在集合中查找,但仍然没有得到工作。

请建议我任何更好的方法。

像这样的表:

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

这里假设我要“ test1”帖子的最近博客帖子,那么答案应该是5、3、2、4

首先与标签匹配,然后如果标签计数相同,则按ID匹配

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

暂无
暂无

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

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