Friday, June 28, 2013

Join Query

Hi,


I have 2 tables as below. My problem is I want to return Task names even if no task records exist.


So for example, there is no data for 2013/06/30. But I still want the task names to be listed...



Output:

name status
RunSpreadsheet NULL
GenerateReport NULL
ReportApproval NULL
PublishReport NULL

Here is my query...



SELECT t.name, tr.status
FROM Tasks t
LEFT JOIN
TaskRecords tr
ON t.taskid = tr.taskid
WHERE taskDate = '2013/06/30'

And the tables...



Any ideas how to do this?


Thanks!


No comments:

Post a Comment