Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Unanswered: Select from subquery set and translate ID into a value

    SQL Server 2000 T-SQL question

    How do I select from a subquery set and translate an ID column into a value(stored in another table) ?

    Here's what I'm trying to do :

    Employee
    ======
    Who State StatusID
    ---------------------------
    Jason FL 2
    John FL 1
    Mary MA 2
    Paul FL 1
    Kevin MA 3

    Status
    =====
    StatusID Label
    ---------------------
    1 FullTime
    2 Contractor
    3 PartTime

    List everyone in FL and displays employment status as label instead of ID, it should display :
    Who State Label
    -----------------------
    Jason FL Contractor
    John FL FullTime
    Paul FL FullTime

    Is this the right way to do it :
    select e.who, e.state, s.label
    from
    status s, (select * from employee where state="FL") e
    where
    employee.StatusID=status.StatusID

    Thanks.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT e.who
         , e.state
         , s.label 
      FROM employee AS e
    INNER
      JOIN status AS s
        ON s.StatusID = e.StatusID
     WHERE e.state = 'FL'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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