Search code examples
sqloracle10g

SQL: Find the Hotels which are booked today


I have a database, which consists of the following tables

HOTEL2(hno, hname, city, phone, room_type, price) 
GUEST2(gno, gname, address, phone) 
BOOKING2(Hno, gno, date_from, date_to) 

I want to get all the information of today's booking. I have written the following query but it's not working properly.

SQL> SELECT *
  2  FROM BOOKING
  3  WHERE DATE_FROM=(SELECT SYSDATE FROM DUAL);

no rows selected

I am using Oracle 10g.


Solution

  • try like below by using trunc

        SELECT b.*
        FROM BOOKING b
        WHERE DATE_FROM=trunc(sysdate)