How can I display those records / customers details who stayed more then 2 days in hotel?
Table Rooms contains arrival and check out dates
Table Customer contains customer details. Both are connected via a primary key that is the room id.
Rooms
arrival | checkout | roomid |
---|---|---|
2/2/2004 | 2/3/2004 | 01 |
2/2/2004 | 2/3/2004 | 02 |
Customer
cust name | room id |
---|---|
raj | 01 |
rohan | 02 |
Output
arrival | checkout | room id | cust name |
---|---|---|---|
2/2/2004 | 2/3/2004 | 02 | rohan |
(ordering not mandatory, cust name can be 1st too)
2
Answers
A simple
inner join
can do the trick :Try it here : https://dbfiddle.uk/dOnB7W9_
It’s a bit weird that you have one customer per room (and not per room and time), but ok.