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 |
james_b
Starting Member
9 Posts |
Posted - 2004-09-07 : 13:06:45
|
I have a select statement as follows:select table_name, table_row_id from Table_LinkThat produces:Organization, 1Organization, 2Organization, 3Country, 1Country, 2etcWhat I need to do is select the data from the relevant table and row_id in the same step, producing something similar to this pseudo-code:Organization, 1, (select name from organization table where row_id = 1)Organization, 2, (select name from organization table where row_id = 2)Organization, 3, (select name from organization table where row_id = 3)Country, 1, (select name from country table where row_id = 1)Country, 2, (select name from country table where row_id = 2)So the second half of the sql statement depends on the values that the first half retrieves...hope this makes sense, thanks for any help :)James |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-07 : 13:53:01
|
will this help?select table_name, table_row_id, '(select name from' + table_name + ' where row_id = ' + table_row_id + ')'from Table_LinkGo with the flow & have fun! Else fight the flow |
|
|
|
|
|
|
|