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 |
|
gmerideth
Starting Member
10 Posts |
Posted - 2004-02-22 : 21:20:32
|
| I have one table with event actions that I have no control over. They are listed as basic #'s (1001 through 1544). I created another table with all of the event descriptions but now I'm looking for a way to make a select that would return values from the event table but instead of the cryptic #'s use the long descriptions from my 2nd table.so instead of a "SELECT eventCode, eventPosition from sbsEvents WHERE {stuff...}" and getting back "1049,11", "1433,22" I could get back "ABS Ord Battery Recharge,11" and "ABS Battery Discharge Failed,22"I would like to have SQL return the long desc from my table and the position value from the original table but I can't quite see how, possibly using a #temp table? I need the output from the first table to be a lookup for values in the second table.I do this now with two (and three) sets of queries using ASP.net but their has to be an easier way I think. |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-02-22 : 23:57:05
|
You won't need temp tables for this, all you need is an INNER JOIN.Assuming your Event Description table has the following columns: eventCode, eventDescription; all you need is a join between the two tables like so - SELECT sbsEvents.eventCode, sbsEvents.eventPosition, sbsEventDescription.eventDescription FROM sbsEvents INNER JOIN sbsEventDescription ON sbsEvents.eventCode = sbsEventDescription.eventCode This is the best I can do without knowing your table structures. Read more about topics such as joining tables in the Books Online.OS |
 |
|
|
|
|
|