Question

How would you rewrite this query using a method other than Union, the method that is...

How would you rewrite this query using a method other than Union, the method that is currently being used. I need this same query rewritten, and if possible in a syntax that will work with Microsoft Access, as that is the platform that I have to test it.

Here is the original query to be rewritten using a query other than Union:

(SELECT EmployeeName

FROM Employee_t E1, EmployeeSkills_t ES1, Skill_t S1

WHERE E1.EmployeeID = ES1.EmployeeID AND ES1.SkillID = S1.SkillID

              AND S1.SkillDescription = ’12in Band Saw’)

MINUS

(SELECT EmployeeName

FROM Employee_t E2, EmplpoyeeSkills_t ES2, Skills_t S2

WHERE E2.EmployeeID = ES2.EmployeeID AND ES2.SkillID = S2.SkillID

              AND S2.SkillDescription = ‘Router’)

So effectively in the end this needs to be written without MINUS, in any other query form. I am trying to understand how to convert from Union as that is the only one that I am currently good in and I need to learn other ways of writing queries.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

you can achieve the same result using a subquery

SELECT DISTINCT E1.EmployeeName
FROM  Employee_t E1, EmployeeSkills_t ES1, Skill_t S1
WHERE E1.EmployeeID = ES1.EmployeeID AND ES1.SkillID = S1.SkillID AND 
S1.SkillDescription = ’12in Band Saw’
NOT IN (SELECT EmployeeName FROM Employee_t E2, EmplpoyeeSkills_t ES2, Skills_t S2 
WHERE E2.EmployeeID = ES2.EmployeeID AND ES2.SkillID = S2.SkillID AND S2.SkillDescription = ‘Router’)

OR

SELECT E.EmployeeName 
FROM Employee_t E,Skills_t s
JOIN EmplpoyeeSkills_t ES ON (E.EmployeeID = ES.EmployeeID)
where S1.SkillDescription = ’12in Band Saw’
Add a comment
Know the answer?
Add Answer to:
How would you rewrite this query using a method other than Union, the method that is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT