Select lookup code values problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Select lookup code values problem

    I have a table called Orders with three fields, OrderID, Action,Status.
    Action and Status are code values with FK lookup to dbo.Action and
    dbo.Status respectively.

    Is it possible for me to return not just the code values but the filed
    names?
    For example:
    SELECT OrderID,Action, Status FROM Orders:
    Returns 1001,B,F

    However I would like dboAction.Actio nName and dbo.Status.Stat usName to be
    returned instead.
    I.e Returns 1001,BUY,Filled .

    Is this possible?

    Thank you.


  • David Portas

    #2
    Re: Select lookup code values problem

    SELECT O.orderid, A.actionname, S.statusname
    FROM Orders AS O
    JOIN Action AS A
    ON O.action = A.action
    JOIN Status AS S
    IN O.status = S.status

    --
    David Portas
    SQL Server MVP
    --


    Comment

    • Steve

      #3
      Re: Select lookup code values problem

      Great. Thank you David.

      "David Portas" <REMOVE_BEFORE_ REPLYING_dporta s@acm.org> wrote in message
      news:54-dnW3_LI4FVCvdRV n-jA@giganews.com ...[color=blue]
      > SELECT O.orderid, A.actionname, S.statusname
      > FROM Orders AS O
      > JOIN Action AS A
      > ON O.action = A.action
      > JOIN Status AS S
      > IN O.status = S.status
      >
      > --
      > David Portas
      > SQL Server MVP
      > --
      >
      >[/color]


      Comment

      Working...