I need to create a query which will show what pens on todays date do not have a bookings in them.
The two tables i would need to use are:
Booking
Pen
I know i need to use the date() function and is null but my query at present is in Sql
SELECT Pen.pen_no, Booking.start_date, Booking.end_date
FROM Pen LEFT JOIN Booking ON Pen.pen_no = Booking.pen_no
GROUP BY Pen.pen_no, Booking.start_date, Booking.end_date
HAVING (((Booking.start_date)<Date()) AND ((Booking.end_date)<Date())) OR (((Booking.start_date)>Date()) AND ((Booking.end_date)>Date())) OR (((Booking.start_date) Is Null) AND ((Booking.end_date) Is Null));
This works but it displays the same pen again if it has had more then one booking in it. How do i make so that i can produce a report that will have just the pens that are free once?
Thanx
Thpus
The two tables i would need to use are:
Booking
- Booking_number (which is the primary key)
- Pen_number (which is the foreign key)
- start_date
- end_date
Pen
- Pen_number (primary key)
- Block_number(which is the foreign key)
I know i need to use the date() function and is null but my query at present is in Sql
SELECT Pen.pen_no, Booking.start_date, Booking.end_date
FROM Pen LEFT JOIN Booking ON Pen.pen_no = Booking.pen_no
GROUP BY Pen.pen_no, Booking.start_date, Booking.end_date
HAVING (((Booking.start_date)<Date()) AND ((Booking.end_date)<Date())) OR (((Booking.start_date)>Date()) AND ((Booking.end_date)>Date())) OR (((Booking.start_date) Is Null) AND ((Booking.end_date) Is Null));
This works but it displays the same pen again if it has had more then one booking in it. How do i make so that i can produce a report that will have just the pens that are free once?
Thanx
Thpus