Help with SQL code

ian_ok

Registered User.
Local time
Today, 22:58
Joined
May 1, 2001
Messages
90
I've doing a hotel d/b and want to prevent double room booking, below is my code, but it doesn't show the correct data when Rooms Available is run...Can you help.

Ian

Rooms Available
SELECT [Rooms].[RoomNum]
FROM Rooms LEFT JOIN [Rooms Reserved] ON [Rooms].[RoomNum]=[Rooms Reserved].[Room]
WHERE ((([Rooms Reserved].[Room]) Is Null));

Rooms Reserved
PARAMETERS [Please enter arrival date] DateTime, [Please enter checkout date] DateTime;
SELECT [Booking].[Room], [Booking].[Arrival], [Booking].[Checkout]
FROM Booking
WHERE ((([Booking].[Arrival]) Between [Arrival] And [Checkout]-1)) Or ((([Checkout]-1) Between [Arrival] And [Checkout])) Or ((([Booking].[Arrival])<[Arrival]) And (([Checkout]-1)>[Checkout]-1));
 
WHERE ((([Booking].[Arrival]) Between [Arrival] And [Checkout]-1)) Or ((([Checkout]-1) Between [Arrival] And [Checkout])) Or ((([Booking].[Arrival])<[Arrival]) And (([Checkout]-1)>[Checkout]-1));
This looks like it maybe an issue since they should be equal if I am reading it correctly
 
SQL code

Is there somewhere that I could download the basic SQL coding, because I can code in MSVB and know that useing code sometime (well most of the time) can get you a more powerfull and accurate d/b. And I would like to start teaching my self SQL.
 

Users who are viewing this thread

Back
Top Bottom