我有一个收集特定数据集的站点。这是一个旅行社网站。有必要确定住宿是否仍可预订。当我不选择任何搜索过滤器(如目的地、分类、设施等)时,我会得到一个有效的查询。看起来像:
SELECT `accommodation` . *
FROM `accommodation`
INNER JOIN (
SELECT `fk_accommodation` , MAX( `dateuntil` ) - ( `releasedays` *60 *60 *24 ) AS `LatestBookableTimestamp`
FROM `priceperiod`
GROUP BY `fk_accommodation`
) AS `pp` ON ( `pp`.`fk_accommodation` = `accommodation`.`id` )
WHERE `pp`.`LatestBookableTimestamp` > UNIX_TIMESTAMP( )
AND `accommodation`.`fk_country` <>0
AND `accommodation`.`classification` >=0
AND `accommodation`.`type` = 'Z'
但是当我选择一个过滤器(在这种情况下是一个“目标”过滤器(儿童、活动、休息、冬季运动等)时,我得到了查询:
SELECT `accommodation` . *
FROM `accommodation` , `link_at`
INNER JOIN (
SELECT `fk_accommodation` , MAX( `dateuntil` ) - ( `releasedays` *60 *60 *24 ) AS `LatestBookableTimestamp`
FROM `priceperiod`
GROUP BY `fk_accommodation`
) AS `pp` ON ( `pp`.`fk_accommodation` = `accommodation`.`id` )
WHERE `pp`.`LatestBookableTimestamp` > UNIX_TIMESTAMP( )
AND `accommodation`.`fk_country` <>0
AND `link_at`.`fk_target`
IN ( 10, 2 )
AND `link_at`.`fk_accommodation` = `accommodation`.`id`
AND `accommodation`.`classification` >=0
AND `accommodation`.`type` = 'Z'
现在,当我执行此查询时,我收到错误:#1054 - Unknown column 'accommodation.id' in 'on clause'
. 我认为这是因为 FROM 子句中使用了另一个表。有没有人知道在查询多个表时如何使用 INNER JOIN?