This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes SQL Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Problem" Watch "SQL Problem" New topic

SQL Problem

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 594
This is a SQL not a java problem, if someone could point me towards a SQL website similar to this i would be happy or if you can solve this problem I would be even happier.
I have two tables EMPLOYEE and WORKING, I want to display all employees mot working. I use the folling SQL Code>
select emp.employeeID,
where wk.employeeID != emp.employeeID

What it returns is all employees not working plus all the employees. So I am getting two lots of data returned.
e.g if Tom Smith is working, James Thomas and Sara Hall are not I get returned
James Thomas
Sara Hall
Tom Smith
James Thomas
Sara Hall
I used to know how to solve this problem but I have forgotten.
Thanks for any help.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32818

You need a subquery:

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 594
Thanks this SLQ code worked.
I agree. Here's the link:
subject: SQL Problem
It's not a secret anymore!