MySQL Forums
Forum List  »  Newbie

Re: Hair Being Pulled Out...
Posted by: Felix Geerinckx
Date: May 13, 2005 05:30AM

Paul Bokor wrote:

> I have two tables, STAFF (a staff list) and DIARY (a diary). They both have a field titled
> FULLNAME. DIARY also has fields titled DATE and ENTRY.
>
> I am trying to get a day's worth of entries where the recordset shows all members of staff, and the
> DIARY.ENTRY shows either the entry or NULL where there is no entry for that person on that day.

Untested:

SELECT
staff.fullname,
IFNULL(diary.entry, 'In the Office')
FROM staff
LEFT JOIN diary ON diary.fullname = staff.fullname AND diary.date = <<some date>>

Where I assume there is at most one record per fullname per date in the diary table.

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
May 13, 2005 05:15AM
Re: Hair Being Pulled Out...
May 13, 2005 05:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.