My MySQL SELECT query is returning all the rows in the table
I'm having trouble with this query. I want to SELECT one project from the
projects table and all of the files associated with it from the projects
table. Here's my query:
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"
;
I was expecting the results to be a set with the columns project_id,
project_password, project_title, project_description, project_active,
file_file, file_title, and file_category (with the first two fields being
the same data for every row returned and the rest varying per file).
Instead of just retrieving the project information and files for
test_project3, this is apparently returning every project in the projects
table.
Any advice?
Thanks!
No comments:
Post a Comment