我在处理这个查询时遇到了问题。我想从表中获取SELECT
一个项目,并从projects
表中获取与其关联的所有文件projects
。这是我的查询:
SELECT
`projects`.`id` AS `project_id`,
`projects`.`password` AS `project_password`,
`projects`.`title` AS `project_title`,
`projects`.`description` AS `project_description`,
`projects`.`active` AS `project_active`,
`files`.`file` AS `file_file`,
`files`.`title` AS `file_title`,
`files`.`category` AS `file_category`
FROM `projects`
LEFT JOIN `files` ON
`projects`.`id` = "test_project3" AND
`files`.`project_id` = "test_project3"
;
project_id
我期望结果是一个包含、project_password
、project_title
、project_description
、project_active
、file_file
、file_title
和列的集合file_category
(前两个字段是返回的每一行的相同数据,其余字段因文件而异)。
这不仅仅是检索项目信息和文件test_project3
,这显然是返回projects
表中的每个项目。
有什么建议吗?
谢谢!