簡體   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