所以我有很多人加入
$manyJoin = "SELECT projects.name AS project_name ,tags.name AS tag_name
FROM `projects` AS projects
LEFT JOIN `project_tags` AS pt
ON projects.id = pt.project_id
LEFT JOIN `tags` AS tags ON pt.tag_id = tags.id
WHERE tags.name IS NOT NULL;";
这给了我这张表
project_name tag_name
project_1 iphone
project_1 android
project_2 android
project_2 windows
我如何使用列出项目标签的列表向每个项目查询此表到echo
。或者我可以重写我的查询以获得我需要的东西吗?感谢。
想要输出。
project_1 iphone android
project_2 android windows
答案 0 :(得分:0)
我会在php中做到这一点:
ORDER BY projects.name