sql - MySQL Statement Displaying Values Even If NULL -
i have 2 tables, employee
& dependent
. employee pk
ssn
, foreign key dependent table essn
. trying retrieve name of employees , names of dependent. if employee not have dependent, need display blank value in dependent column.
to retrieve name of employees have dependents, statement use:
select firstname "first name", lastname "last name", dependent_name "dependent name" employee,dependent ssn=essn;
if guide me in right direction, appreciated.
use left join
rows first table if there no matching in second:
select firstname "first name", lastname "last name", dependent_name "dependent name" employee left join dependent on dependent.essn = employee.ssn;
i changed implicit old-style join ansi compliant explicit join too.
Comments
Post a Comment