daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. writing sql query
  2. SELECT * from room
  3. WHERE (roomNo, hotelNo) not in
  4. ( select roomNo, hotelNo
  5.   from booking
  6.   where datefrom between '2012-05-01' and '2012-11-01'
  7.   or dateto between '2012-05-01' and '2012-11-01'
  8. )
  9.    
  10. select r.* from rooms r
  11. left outer join bookings b on b.roomno = r.roomno
  12. where b.dateto not between '2012-05-01' and '2012-11-01'
  13. and b.datefrom not between '2012-05-01' and '2012-11-01'
  14. or b.roomno is null
  15.    
  16. SELECT * FROM Room r
  17. JOIN Booking b ON b.hotelNo = r.hotelNo AND r.roomNo = b.roomNo
  18. WHERE NOT ('2012-05-01' BETWEEN (b.dateFrom AND b.dateTo)
  19. OR '2012-11-01' BETWEEN (b.dateFrom AND b.dateTo))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top