Updating table using column heading from another table [message #18643] |
Fri, 08 February 2002 05:58  |
andy
Messages: 92 Registered: December 1999
|
Member |
|
|
Is there a way to update one table using the value in another table, but possibly using the column name from that table to link to the original table although this may not be necessary.
Example:
Table1
EQNUM N1
===== ==
1234 4
3456 6
4444 1
Table2
EQNUM ATTRIB NUMVALUE
===== ====== ========
1234 N1
3456 N1
4444 N1
The idea is to use the contents of Attrib from Table 2 to link to the column name in Table 1 with the same column heading and retrieve the value.
The column heading N1 in Table1 will always be the same as the Attrib value in Table2 if this helps in resolving the problem.
I have tried the following, but it obviously brings back multiple rows for each line:
update Table2
set numvalue = (select tab1.n1 from table1 tab1, table2 tab2 where tab1.epnum = tab2.eqnum)
where tab2.attrib = 'N1'
Any help would be much appreciated.
Thanks.
|
|
|
|
|