The SQL Server 2005 table I'm working from is really strange. Here's an example:
key | a | b | c | d | e | f
z 0 1 2 3 4 5 6
y 1 8 9 10 11 12 13
x 14 15 16 17 18 19 20
w 21 22 23 24 25 26 27
What I need to accomplish is to, in a single statement, select the column name from a different table, then get the value here. So it would be something like "Select (select colName from table2 where id=VAR1) From table1 where key = VAR2" So table2 will return either a/b/c/d/e/f, and then the main statement will get the value of the corresponding value based on the key. Table2 will always return a-f, and I will know the VAR1 and VAR2 ahead of time.
Aucun commentaire:
Enregistrer un commentaire