简体   繁体   English

获取具有使用权重的所有标签

[英]Get all tags with usage weight

I'm creating a custom tag system with php and mysql, using the Toxi mysql schema http://forge.mysql.com/wiki/TagSchema#Toxi (three tables, many to many realtionship). 我正在使用Toxi mysql模式http://forge.mysql.com/wiki/TagSchema#Toxi (三个表,很多对很多)创建带有php和mysql的自定义标签系统。

I've seen a lot of examples how to retrieve most used tags, etc etc. ex.g 我已经看到了很多示例,这些示例介绍了如何检索最常用的标签等。例如

SELECT tag_text, COUNT(*) as num_items
FROM Item2Tag i2t
INNER JOIN Tags t ON i2t.tag_id = t.tag_id
GROUP BY tag_text;

But I need to retrieve all the tags in the system (instead of only the used ones), having the usage weight for each, and having the tags not used yet with a weight of zero. 但是我需要检索系统中的所有标签(而不是仅使用的标签),每个标签都有使用权重,并且尚未使用的标签的权重为零。

try the following query, i will get all the tags in Tags table 尝试以下查询,我将在“ Tags表中获取所有Tags

SELECT tag_text, COUNT(i2t.tag_id) as num_items
FROM Tags t
LEFT JOIN Item2Tag i2t ON i2t.tag_id = t.tag_id
GROUP BY tag_text;

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

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