简体   繁体   English

在mysql中获取相关标签(需要帮助)

[英]Get related tags in mysql (need help)

i have a table in mysql 我在mysql中有一张桌子

Table name: related_tags 表名称:related_tags

 tag_1   |   tag_2
....................
 iphone      ipod
 ipad        ipone
 iphone      mac
 iphone      apple
 ipod        ipone
 iphone      ipod
 apple       iphone

i want to print related tags to the iphone from this table.. 我想从此表中将相关标签打印到iPhone。

and the tags which is used more times with iphone should be at 1st 并且iphone使用次数更多的标签应位于1号

eg: ipod (used 3 times), apple used 2 times 例如:ipod(使用3次),苹果使用2次

ipod should be 1st and apple must be 2nd and so on. ipod应该是1st,apple必须是2nd,依此类推。

what will be the exect query 什么是exect查询

The fact that you're numbering your columns shows that something is wrong with your schema in the first place. 您正在对列进行编号的事实表明,您的架构首先存在问题。 You should have one table containing all tags (tagID, tagName) and then a second table where you store the relations (tagID, tagID). 您应该有一个包含所有标签的表(tagID,tagName),然后有另一个表用于存储关系(tagID,tagID)。 This way you can easily query your relations. 这样,您可以轻松查询您的关系。

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

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