Groups | Blog | Home
all groups > sql server (alternate) > may 2004 >

sql server (alternate) : Select lookup code values problem


Steve
5/28/2004 5:00:58 AM
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.ActionName and dbo.Status.StatusName to be
returned instead.
I.e Returns 1001,BUY,Filled.

Is this possible?

Thank you.

David Portas
5/28/2004 6:08:32 AM
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
--

Steve
5/28/2004 9:20:43 AM
Great. Thank you David.

[quoted text, click to view]

AddThis Social Bookmark Button