Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ms960
Starting Member
2 Posts |
Posted - 2011-08-11 : 11:00:44
|
| I'm trying to build a query that performs a lookup in a reference table.My main table has a column named event_id that I need to translate to an event code. I have the event_id, and need the event_code.My lookup table is this:event_id event_code-------- ----------1 12 23 34 45 56 77 108 119 1210 6I am at a loss as to how to build a query to get the event_code, given the event_id. Would very much appreciate some help from the expertise here!Thanks so much! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-11 : 11:06:48
|
| [code]select event_codefrom tablewhere event_id = @eventid[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-08-11 : 11:14:50
|
| SELECT MainTable.column1, Lookup.Event_CodeFROM MainTableINNER JOIN Lookup ON MainTable.Event_ID=Lookup.Event_ID |
 |
|
|
ms960
Starting Member
2 Posts |
Posted - 2011-08-11 : 11:57:22
|
| Thanks so much! Took care of it. |
 |
|
|
|
|
|