Quote:
select ppl.ename as ename , ppl.edept, task.tdate as tdate
from ppl left join task
on ppl.ename=task.ename
where task.tdate='01-oct-2017';
Your
LEFT JOIN
returns all the rows from
ppl
, and any matching rows from
task
. For
ppl
rows which don't have a corresponding
task
row, the result will have
Null
values for all of the
task
columns.
Your
WHERE
clause then filters the result based on the
tdate
column from
task
being equal to a specific value. For
ppl
rows with no
task
rows, this filter will
not be met, because
Null
is not equal to that value.
You need to move the date filter up to the
JOIN
:
SELECT
ppl.ename,
ppl.edept,
task.tdate
FROM
ppl
LEFT JOIN task
ON ppl.ename = task.ename
AND task.tdate = '01-oct-2017'
;