Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. select a.property_id,count(a.booking_id) as total_bookings,
  2. group_concat(concat(date_format(a.check_in,'%m/%d/%Y'),' To ',
  3. date_format(a.check_out,'%m/%d/%Y'),' ','(',(case a.book_status when 1 then 'Pending' when 3 then 'Confirm' end) ,')',' |
  4. <a href='manage_booking.php?action=ed&id=',a.booking_id,'' target=_blank class=linkun >
  5. View Detail</a>','<br>')) as dates FROM apl_property_booking AS a WHERE EXISTS (
  6. SELECT booking_id FROM apl_property_booking AS b WHERE b.booking_id != a.booking_id and
  7. b.property_id=a.property_id AND (b.check_in < a.check_out AND a.check_in < b.check_out)
  8. and b.book_status in (1,3) and ('2015-04-01' <= date_add( b.check_out, INTERVAL -1 DAY )
  9. AND '2015-04-27' >= date_add( b.check_in, INTERVAL +1 DAY )) ) and a.book_status in (1,3)
  10. and ('2015-04-01' <= date_add( a.check_out, INTERVAL -1 DAY ) AND
  11. '2015-04-27' >= date_add( a.check_in, INTERVAL +1 DAY )) group by a.property_id
  12. order by a.check_in desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement