I were given three tables
Lakes - identification,name,lat,lon
Pegs - id, pegnumber, pegname,lake_id
Reservations- identity, start_day,end_day , peg_id
I am attempting to write the question who return me the listing of unbooked pegs on a lake at some point or among two dates. I wrote that query however they return me best already booked.
SELECT l.name,p.id,p.peg_number,r.start_day,r.end_day
FROM reservations r
left join pegs p on r.peg_id = p.id
left join lakes l on p.lake_id = l.id
WHERE r.start_day is not null
order by l.name
0 Replies