0

Let's say I have a table a table of employees and another employee_address.

Additionally, I have a table of employee_email_address (employees don't have to have an email)

select 
    employee.emp_id, 
    employee_address.address, 
    employee_email_address.email
from  
    employees 
inner join
    employee_address on employee.emp_id = employee_address.emp_id
inner join 
    employee_email_address on employee_email_address.emp_id = employee.emp_id

but what this query is giving me is only the employees who have an address AND an email address....

How can I include rows for which there is no email_address for the employees? (Note, the email address is not null)

Thanks.

2 Answers 2

1

Use left join instead of inner join.

Sign up to request clarification or add additional context in comments.

1 Comment

I did, and it is still not adding these fields.
1

Try this query:

Select e.emp_id, ea.address, eea.email
from employees e left join
     employee_address ea
     on ea.emp_id = e.emp_id left join
     employee_email_address eea 
     on eea.emp_id = e.emp_id;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.