I am trying to create an SQL statement for a calendar system and I having some difficulty. I am using mySQL v3.23.53 running on Win2k.
I have the the following tables;
User Table:
Status
username
fullname
Calendar table:
id
username
stdate
enddate
caldesc
notes
I am tring to create a "SELECT" statement that returns the calendar entries for a specific date linked to the user as well as all of the users who DO NOT have entries in the calendar.
Something like;
username Stdate enddate caldesc
bill 2003-05-20 2003-05-30 Doing something
george null // no calendar entries
mary null // no calendar entries
Danny 2003-05-21 0000-00-00 Doing something
To date I have tried a number of things including a LEFT JOIN as follows;
SELECT u.username, d.stdate,d.enddate,d.caldesc,d.note
FROM webuser as u
LEFT JOIN caldates as d USING (username)
WHERE (d.stdate = "2003-05-30" or "2003-05-30" between d.stdate and d.enddate or d.stdate IS NULL)
This SQL returns all of the calendar entries, BUT only returns one user who do not have entries in the calendar table, when it should return 8 users with no entries for that date.
So ... anyone have any suggestions ??