My SQL query below says that it is not ended properly on the first Inner Join?If i remove the second table and the where clause the query is fine though?
SELECT homes.home_id, homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft,
listagg(features.feature_name, '\n') WITHIN GROUP(ORDER BY features.feature_name) features, home_type.type_name
FROM homes, bookings
WHERE bookings.booking_end < date '2013-01-23' OR bookings.booking_start > date '2013-01-22' AND bookings.home_id <> homes.home_id
INNER JOIN home_feature ON homes.home_id = home_feature.home_id
INNER JOIN home_type ON home_type.type_code = homes.type_code
INNER JOIN features ON home_feature.feature_id = features.feature_id
GROUP BY homes.home_id, homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, home_type.type_name
Can anybody see any obvious errors with my query?
Your
WHEREclause is in the wrong place and you are mixing join types:The
WHEREclause appears after theJOINand beforeGROUP BY. Also you should use one type of of join syntax. You were using both explicit and implicit syntax. I moved the join ofhomesandbookingto aJOINinstead of using a comma between the tables.