Can someone explain to me which syntax matches this SQL query?
SELECT DISTINCT boats.boatid
FROM boats LEFT JOIN reservations ON
reservations.boatid = boats.boatid
and (@paramFromDate <= reservations.to AND reservations.from <= @paramToDate )
WHERE reservations.to IS NULL
tables:
**boats** boatid
**reservations** reservationid, fk_boatid, from, to
The idea behind the query is to get unreserved boats for a date range marked with parameters. Any boat that has any part of the range covered even partially is not available.
How is this "and ..." code there? Why is he missing something like the WHERE keyword? It seems WHERE is implicit here?
source
share