Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Minus Query

Posted on 2004-09-20
10
Medium Priority
?
11,014 Views
Last Modified: 2012-08-13
I am looking for a solution that would be similar to Oracle's minus query.  I have two tables, an employee table and an employee_skill table.  I need a query that will pull out all employees that do not have a certain skill.

example:  Select * from employee, employee_skill
               where employee.empid = employee_skill.empid

               MINUS
 
               Select * from employee, employee_skill
               where employee.empid = employee_skill.empid
               and skill_id = 2 //or whatever skill#
             
0
Comment
Question by:d_vonfeldt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 12106204
Select * from employee, employee_skill inner join employee.empid = employee_skill.empid where employee_skill <> 2;
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 800 total points
ID: 12106282
SELECT * FROM employee WHERE empid NOT IN (SELECT empid FROM employee_skill As A WHERE A.skill_id=2 AND A.empid=employee.empid)
0
 

Author Comment

by:d_vonfeldt
ID: 12106284
Select * from employee, employee_skill inner join employee.empid = employee_skill.empid where employee_skill <> 2;

that line of code gave me a syntax error in FROM clause message.

Is that line equivalent to: Select * from employee, employee_skill
                                    where employee.empid = employee_skill.empid
                                    and skill_id <> 2.

I am not too familiar with inner joins?
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:d_vonfeldt
ID: 12106353
Thanks,

That was quick and easy.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 12106412
Sorry, I got it wrong. For the record, I think it should be:

Select * from employee inner join employee.empid = employee_skill.empid where employee_skill <> 2;
0
 
LVL 44

Expert Comment

by:GRayL
ID: 12106424
Still got it wrong:

Select * from employee inner join employee.empid = employee_skill.empid where employee_skill.skill_id <> 2;
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12106476
GRayL, you have not specified the join table in your query. It should read (modifications in caps):

Select EMPLOYEE.* from employee inner join EMPLOYEE_SKILL ON employee.empid = employee_skill.empid where employee_skill.skill_id <> 2;

However, this only returns records where the skill_id is not 2 - if an employee has skill 2, it simply doesn't include that record in the list, but includes all of his other skill records. It doesn't return records for employees who don't have skill 2 at all.
0
 

Author Comment

by:d_vonfeldt
ID: 12106489
I am still getting the same error when using

Select * from employee inner join employee.empid = employee_skill.empid where employee_skill.skill_id <> 2;
0
 

Author Comment

by:d_vonfeldt
ID: 12106513
perfect explanation shanesuebsahkarn,  that is what was giving me the troubles.

0
 
LVL 44

Expert Comment

by:GRayL
ID: 12106666
Nicely done Shane.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question