<分区>
我试图通过连接五个表来创建图像的过滤器输出。由于我的 where 语句,我需要连接五个表。我的 sql 如下:
SELECT `files`.`id` AS `id`,
`files`.`name` AS `name`,
`files`.`size` AS `size`,
`files`.`type` AS `type`,
`files`.`url` AS `url`,
`files`.`title` AS `title`,
`files`.`description` AS `description`,
`files`.`category` AS `category`
FROM `files`
INNER JOIN `folders`
ON `files`.`category` = `folders`.`id`
INNER JOIN `access`
ON `access`.`folder_id` = `folders`.`id`
INNER JOIN `tags_files`
ON `tags_files`.`file_id` = `file`.`id`
INNER JOIN `tags`
ON `tags`.`id` = `tags_files`.`tag_id`
WHERE ( `access`.`user_id` = 11 )
AND ( `files`.`type` = 'application/x-photoshop'
OR `files`.`type` = 'image/jpeg'
OR `files`.`type` = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' OR type = 'application/download'
OR `files`.`type` = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
OR type = 'application/msword'
OR `files`.`type` = 'application/postscript'
OR `files`.`type` = 'image/png'
OR `files`.`type` = 'application/pdf'
OR `files`.`type` = 'image/tiff'
OR `files`.`type` = 'image/gif'
OR `files`.`type` = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
OR `files`.`type` = 'application/octet-stream'
OR `files`.`type` = 'application/zip'
OR `files`.`type` = 'text/plain' OR `files`.`type` = 'text/rtf' )
AND ( `tags`.`name` = 'apple' )
我开始时只有三个表:
files, folders, access
一切顺利,但添加了最后两个
tag, tags_files
我收到以下错误:
1054 - Unknown column 'file.id' in 'on clause'
这很奇怪,因为那是我开始时使用的表格...感谢您的帮助!