SQL queries

Discussion in 'OT Technology' started by purebad, Nov 15, 2006.

  1. purebad

    purebad I don't need your approval, right?

    Joined:
    Aug 25, 2006
    Messages:
    4,376
    Likes Received:
    0
    Location:
    Smyrna, GA
    lives = (person, street, city, state)
    works = (person, company, dept, salary)
    located_in = (company, city, state)
    manages = (person, dept)

    is the table scheme

    Find the name, street, and city of all employees who work for UK or earn more
    than $18,000.

    SELECT L.person, L.street, L.city
    FROM works W, lives L
    WHERE W.person=L.person AND (W.company=“UK” OR W.salary>18000)

    is the answer given, but can you also use a natural join with works and lives such as:

    SELECT person, street, city
    FROM works NATURAL JOIN lives
    WHERE company = "UK" OR salary>18000
     
  2. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Whats your question?
     
  3. Coottie

    Coottie BOOMER......SOONER OT Supporter

    Joined:
    Jun 6, 2006
    Messages:
    32,407
    Likes Received:
    0
    Location:
    OKC
    His question is stated in the OP...perhaps you should read it. :p

    And to answer the question, yes I believe it would work but to be certain....why not code it up and try it?? Should take less time than it did to type the question.
     
  4. purebad

    purebad I don't need your approval, right?

    Joined:
    Aug 25, 2006
    Messages:
    4,376
    Likes Received:
    0
    Location:
    Smyrna, GA
    Im less inclined to code it up because of populating the tables with sufficient data to properly see if it it correct in all sets of possible data :p
     

Share This Page