0

I am trying to count the number of bookings for the next 7 days with the following query.

select calendarDate, 
   (
    select COUNT(*)
    FROM isBooked INNER JOIN booking
    ON isbooked.BookingID = booking.bookingID
    where specificday between booking.startDate and booking.endDate
    ) 
from calendar as specificday
where calendardate between  '2015-08-23' and DATE_ADD('2015-08-23', INTERVAL 6 DAY);

I have used SQL server which allows the use of 'as specificday' however MySQL does not, how would i rewrite the query in mysql.

0

1 Answer 1

1

specificday refers to a table, not a column. You need a column name for the WHERE clause:

select c.calendarDate, 
       (select COUNT(*)
        from isBooked ib INNER JOIN
             booking b
             ON ib.BookingID = b.bookingID
        where c.calendarDate between b.startDate and b.endDate
       ) 
from calendar c
where c.calendardate between '2015-08-23' and DATE_ADD('2015-08-23', INTERVAL 6 DAY);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.