Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting data when no record in the 'linked' table

Status
Not open for further replies.

nekrecart

Programmer
Feb 3, 2004
6
BE
How can I still select data when the specified record has no entry in the linked table?

Select *
FROM Employees e , Computers c
WHERE e.EmployeeID = c.EmployeeID

With this statement I will get all the employees that have a computer assigned to them. But I also want the employees without a computer in the list.

Example like this :
01 - JOHN - DELL 2400
02 - DARREN - HP PIV
03 - DAVID -
04 - BILL - DELL 2400

Thanks,
 
Look up OUTER JOINS in Books Online. Also get used to using ANSI join syntax rather than "old" way of using the WHERE clause:

Code:
SELECT *
FROM employees e LEFT JOIN computers c ON e.employeeid = c.employeeid

--James
 
Ha thanks it worked.

I was already wondering what that strange SQL notation was. I learned 2 new things today ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top