mysql - Show all rooms and reservation -
i have 3 table
type (id, libel)
bedroom (id, name, type)
reservation (id, name, libel, start_date, end_date, room)
i want make application rooms , reservations between 2 dates. have following query
$sql = 'select r.id, r.name, r.start_date, r.end_date, r.libel, r.statut ,c.name room, t.libel type ' . 'from type t inner join bedroom c on t.id = c.type left join reservation r on c.id = r.room' . 'where ( :start_date between r.start_date , r.end_date ' . ' or :end_date between r.start_date , r.end_date' . ' or r.start_date between :start_date , :end_date' . ' or r.end_date between :start_date , :end_date) order c.'.$ordercolumn.' asc';
but appears rooms reserved between start_date , end_date.
$sql = 'select reservation.*, bedroom.*, type.* reservation ' . 'right join bedroom on reservation.room = bedroom.id ' . 'inner join type on bedroom.type = type.id' . 'where $somedate between $startdate , $enddate' . 'order $ordercolumn asc;'
does work ? way not using as
clauses in select
. :start_date
, :end_date
refer ?
Comments
Post a Comment