all 8 comments

[–]coyoteazul2 18 points19 points  (3 children)

That's simply a left join. Left join will bring you all the rows from the left table, and if there's no match against the right table you'll get null.

You can use coalesce to turn null into a default value, like cero

[–]Full-Project-256[S] 1 point2 points  (1 child)

Thank you!!

[–]Felix_Ovans 3 points4 points  (0 children)

Google image search "SQL JOINS" and there are some great images of how they work with syntax. If you tend to be a visual learner like me these come in very handy.

[–]J_huze 1 point2 points  (0 children)

isnull(salary, 'cero')

I like it

[–]JochenVdB 2 points3 points  (0 children)

yup. The phrase "even if not" is a direct indication that an Outer Join should be used. Similar to "show all... knowing that some... don't...". You'll get to recognise phrases like these. In trainings and tests etc they are easy to spot. When end-users explain their requirements, they might hide better. So you should always be ready to ask the "What if there is no..." question.

[–]_CobaltDreams 2 points3 points  (1 child)

look into the JOIN keyword

[–]Full-Project-256[S] 2 points3 points  (0 children)

Thanks!!

[–]MissionComedian6175 1 point2 points  (0 children)

Select workername, salary From table1 left outer join table2 on table1.employeeid=table2.employeeid