我有这个查询
SELECT f.id_film, title, year, GROUP_CONCAT(actor SEPARATOR '|') AS 'actors',
GROUP_CONCAT(director SEPARATOR '|') AS 'directors'
FROM film f JOIN middle m ON f.id_film = m.id_film
JOIN actors a ON m.id_name = a.id_actor
JOIN directors d ON m.id_name = d.id_director
WHERE id_category = "com" GROUP BY f.id_film
这应该从表演员和表导演那里收集名字。中间表实际上是两个表之间的“连接器”,并通过一个包含“a”或“d”值的列“type”将一个表与另一个表区分开来。我无法正确地将演员与导演分开,这意味着查询返回所有 id,无论类型如何。我尝试了子查询但没有成功。任何建议将不胜感激。谢谢