我的查询如下:
SELECT collection_content_mappings.tbl_content_common_id
FROM collection_content_mappings Inner Join tbl_content_commons ON collection_content_mappings.tbl_content_common_id = tbl_content_commons.id
INNER JOIN tbl_content_additionals ON collection_content_mappings.tbl_content_common_id = tbl_content_additionals.content_content_code
WHERE collection_content_mappings.collection_id = 1
这部分是问题所在:
collection_content_mappings.tbl_content_common_id = tbl_content_additionals.content_content_code
字段“collection_content_mappings.tbl_content_common_id”不是那里需要等同的字段;相反,我必须采取tbl_content_commons.content_common_code from tbl_content_commons where collection_content_mappings.tbl_content_common_id = tbl_content_commons.id
。如何将其添加到上面的查询?
感谢任何帮助
答案 0 :(得分:1)
在构建查询时,您应该重命名表。 我不知道我是否理解你想要什么,但我认为这是这样的:
SELECT tbl_content_commons.id
FROM tbl_content_commons
Inner Join collection_content_mappings ON collection_content_mappings.tbl_content_common_id = tbl_content_commons.id
INNER JOIN tbl_content_additionals ON tbl_content_additionals.content_content_code = tbl_content_commons.content_common_code
WHERE tbl_content_commons.id = 1