Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include Null value in Join?

Tags:

sql-server

I have a table where in the column 'AssignedRecruiter' has numerical values (Id). And it can have null values as well.

The Id stored in this column are also present in Employee table which consists of names of Employees. On executing Join between two tables based on Table1.AssignedRecruiter = Employee.Id , I get all the values from Employee table matching with the Id of 'AssignedRecruiter'.

However I wish to have all the null values as well. I tried Left join for picking all value from Table1 but it doesnt work.

like image 946
Jainam Desai Avatar asked Jun 10 '26 19:06

Jainam Desai


1 Answers

Use a LEFT JOIN, it will add all the records from table1 to your result set.

SELECT *
FROM table1 t
LEFT JOIN Employee e ON t.AssignedRecruiter = e.Id
like image 176
Jibin Balachandran Avatar answered Jun 18 '26 22:06

Jibin Balachandran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!