我有以下查询(嗯......让我烦恼的部分):
SELECT DISTINCT `serv`.`id`, `serv`.`name`, `prj`.`id` AS `idProject`, `prj`.`name` AS `projectName`, `units`.`id` AS `idUnit`,
`units`.`name` AS `unitName`, `units`.`description` AS `unitDescription`, `units`.`descriptionLong` AS `unitLongDescription`,
`units`.`address`, `units`.`telephone`, (
SELECT DISTINCT GROUP_CONCAT(CONCAT(`subserv`.`id`, '|', `subserv`.`name`, '|', `links`.`continuous`))
FROM `" . DBT_SERV . "` AS `subserv`
JOIN `" . DBT_SERV_LINKS . "` AS `links` ON (
`links`.`deleted` = 0 AND
`links`.`idProject` = `serv`.`idProject` AND
`links`.`mandatory` = '1' AND
`links`.`subserviceLink` = 1 AND
`links`.`serviceFrom` LIKE CONCAT ('|', `serv`.`id`,'|') AND
`links`.`serviceTo` LIKE CONCAT('|', `subserv`.`id`, '|')
)
WHERE `idParentService` = `serv`.`id`
AND `subserv`.`deleted` = 0
AND `subserv`.`onSaleStatus` = 'onSale'
AND `subserv`.`serviceGroup` = 'SS'
) AS `subservices`, (
SELECT `file`
FROM `" . DBT_GALLERY . "` AS `gallery`
WHERE `gallery`.`category` = 'accommodationUnit'
AND `idObject` = `idUnit`
LIMIT 1
) AS `picture`
FROM `" . DBT_SERV . "` AS `serv`
ETC.,ETC ......更多的连接和位置。
我的问题是我收到以下错误:#1054 - Unknown column 'serv.idProject' in 'on Clause'
如果我删除 links
. idProject
= serv
。idProject
我得到#1054 - 'on 子句'中的未知列'serv.id ='。
serv
基本上......我在 ON 子句中看不到任何东西。如果我删除整个 JOIN 查询工作,那么在 WHERE 子句serv
中是可见的。知道如何使它在 ON 子句中也起作用吗?