Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 10-09-2010, 08:34 AM Help with Left Join
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
I have a table called Employees with a one-to-many relationship to a table called EmpDepts. I have a Departments table containing department records.

EmpDepts contains records of the departments an employee has been assigned to and an employee can be assigned to any number of departments.

So the tables look like this:

Employees:
id last_name
23 Smith
45 Jones
50 Banks
55 Wilson
77 Harris

EmpDepts:
emp_id dept_id
23 63
45 63

Departments
id label
63 Sales
18 Support
23 Accounting

I'm trying to write a query that will show me all employees not assigned to Sales but it only shows me those employees who are in the EmpDepts table and I think that's because of the left join query. How can I write a query that will show Banks, Wilson and Harris as not being assigned to the Sales department? Thanks.

PHP Code:
SELECT E.last_name
FROM Employees E
LEFT JOIN EmpDepts D ON E
.id=D.emp_id
WHERE D
.dept_id <> 63 
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Help with Left Join
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08480 seconds with 12 queries