Hi all,
I have a site where a specific set of data is collected. This is a travel agency website. It is neccesary to determine whether or not an accommodation is still bookable. When I don't select any searchfilters (like destination, classification, facilities etc) I get a working query. The looks like:
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'
But when I select a filter (in this case a 'target' filter (children, active, rest, wintersports etc) I get the query:
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'
Now when I execute this query I get the error: #1054 - Unknown column 'accommodation.id' in 'on clause'
. I think this is because another table is used in the FROM clausule. Does anyone have an idea on how to use the INNER JOIN when multiple tables are queried??
Any help would be greatly appreciated.
Ben Fransen