Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Posts
    2

    Unanswered: intro to sql help

    i am alot of questions and no help from my instructor so i have turned to the net can anyone help me out with this query

    SELECT E.Employee_Name, S.Skill_Description
    FROM EMPLOYEE_t AS E, Employee_Skills_t AS E2, SKILL_t AS S
    WHERE E.Employee_ID = E2.Employee_Id AND
    S.Skill_Id = E2.Skill_Id AND
    S.Skill_Description="12in Band Saw";

    this statement pulls all the people with skills to use a 12in band saw but i need it to be a IN statement and if i do this

    SELECT E.Employee_Name
    FROM EMPLOYEE_t AS E, Employee_Skills_t AS E2
    WHERE E.Employee_Id IN (
    SELECT S.Skill_Description
    FROM SKILL_t AS S
    WHERE E2.Employee_Id = S.Skill_Id AND S.Skill_Description="12in Band Saw");

    i do not get anything all my insructor could tell me was that it doesnt make sense and i dont need the employee id in both statements.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Does this help?

    WHERE E.Employee_Id IN (
    SELECT S.Skill_Description
    Paul

  3. #3
    Join Date
    May 2010
    Posts
    2
    i worked it out to get this

    SELECT E.Employee_Name
    FROM EMPLOYEE_t AS E
    WHERE E.Employee_ID IN
    (SELECT ES.Employee_Id
    FROM Employee_Skills_t AS ES
    WHERE ES.Skill_Id IN
    (SELECT S.Skill_Id
    FROM SKILL_t AS S
    WHERE S.Skill_Description = "12in Band Saw"))

    but now how do i get employees that do not know how to use the saw actuall despite using <> is there any other way to get not because this will still bring up the same people just for different skills

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    For starters, you're using what many consider to be an outdated and less efficient method, that is using the WHERE clause instead of JOIN's. In other words, this

    SELECT *
    FROM employee, department
    WHERE employee.DepartmentID = department.DepartmentID

    could (should?) be:

    SELECT *
    FROM employee
    INNER JOIN department
    ON employee.DepartmentID = department.DepartmentID

    That will also gain you some flexibility with the type of join (INNER, LEFT, RIGHT, ...). On to your question, I would create a query that finds those employees that have the skill. Then use the unmatched query wizard to compare the table of all employees with that query. That will result in those that don't have the skill.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •