Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL question Please pay attention to the requirements, there should be four cond

ID: 3815747 • Letter: S

Question

SQL question

Please pay attention to the requirements, there should be four conditions.

answer this question:

--Finding out all the guests who stayed in Grosvenor hotel during September.

*according to the professor, there should be four conditions:

see this picture:

dateFrom >= 1/9 AND <= 30/9 --first condition

OR ( ) --second condition

OR ( ) --third condition

OR ( ) --fourth condition

*please also make the code as efficient as possible

Thank you!!

Schema Hotel (hotelNo, hotelName, city) Room (roomNo hotelNo, type, price) Booking (hotelNo uestNo, date Fro dateTo roomNo) Guest (guestNo, Nam guestAddress)

Explanation / Answer

Solution:

SELECT guestNo, guestName FROM Guest INNER JOIN Booking ON Guest.guestNo= Booking.guestNo INNER JOIN Room ON Room.hotelNo= Booking,hotelNo INNER JOIN Hotel ON Hotel.hotelNo= Room.hotelNo WHERE dateFrom>=1/9 AND dateFrom <=30/9 OR dateFrom>=1/8 AND dateFrom <=30/8 OR dateFrom>=1/10 AND dateFrom <=30/10 OR dateFrom>=1/8 AND dateFrom <=30/10.

This wiil do the job for the given four conditions.

I hope this helps. Don't forget to give a thumbs up if you like this.