• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQL Problem

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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, emp.name
from EMPLOYEE emp,WORKING wk
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.
Tony
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tony,
You need a subquery:
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks this SLQ code worked.
Tony
reply
    Bookmark Topic Watch Topic
  • New Topic