hotel reservation system SQL: identify any room available in date range

前端 未结 1 1871
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 16:01

(In case this seems familiar: I asked a different question similar to this one, but I just got a note that the site design has changed and now the owners do want a

相关标签:
1条回答
  • 2021-01-14 16:41

    If I understood your db structure properly, you need to find a row in rooms with no corresponding rows in availability.

    SELECT r.* 
    FROM rooms r
      LEFT JOIN availability a ON (r.id = a.room_id 
     AND a.date_occupied BETWEEN :start_date AND :end_date)
    WHERE a.id IS NULL
    
    0 讨论(0)
提交回复
热议问题