K
Kate
I have the following query
SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, AVAILABILITY.Day, AVAILABILITY.BookingID
WHERE (AVAILABILITY.BookingDate >= StartDate AND
AVAILABILITY.BookingDate <= EndtDate AND AVAILABILITY.Day
= DayNumber)
which returns all the records for a particular day of the
week between 2 dates. I'm an SQL novice so I was pleased I
got this to work!
However what I really want to do is check the BookingID
for each record returned by the above query and if it is 1
for every record returned then take action 1 else take
action 2 (output a message saying not all dates available)
Can I do this with SQL or do I have to write some code?
(It's a bit like executing the above SQL statement,
getting a record count, then executing another SQL
statement as aove but with an added AND BookingID = 1 and
getting this count, then comparing the counts, if equal
action 1 else action 2. So is there an SQL construct that
counts matching records and puts them in a variable?)
Thanks
SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, AVAILABILITY.Day, AVAILABILITY.BookingID
WHERE (AVAILABILITY.BookingDate >= StartDate AND
AVAILABILITY.BookingDate <= EndtDate AND AVAILABILITY.Day
= DayNumber)
which returns all the records for a particular day of the
week between 2 dates. I'm an SQL novice so I was pleased I
got this to work!
However what I really want to do is check the BookingID
for each record returned by the above query and if it is 1
for every record returned then take action 1 else take
action 2 (output a message saying not all dates available)
Can I do this with SQL or do I have to write some code?
(It's a bit like executing the above SQL statement,
getting a record count, then executing another SQL
statement as aove but with an added AND BookingID = 1 and
getting this count, then comparing the counts, if equal
action 1 else action 2. So is there an SQL construct that
counts matching records and puts them in a variable?)
Thanks