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

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -