Help: update multiply columns in table
Posted in 1995
Topics: General Discussion
I am trying to write a SQL to produce a report. The final report includes
statistics for 15 cities (one column for each city). I write the result into a
temp table first, there are only 3 columns in the temp table (city, halfhr,
col1). Then I write the following SQL to insert the result into the result
table which has 15 columns (one for each city). I use the following statements:
insert into result_tableselect
halfhr,
col1
from temp_table
where city ='OBK';
update result_table
set(col2) = (select col1 from temp_table where city='DAL')
where temp_table.halfhr = result_table.halfhr
.... After I insert the first city into the result table, I wish to update the
table 14 times by selecting different city name and insert them into the right
column. But, I haven't been able to insert it into the result table, I keep
getting sytax error and I couldn't figure out where it is wrong. Could someone
help me with this problem, is there a better way to do this. Thanks, Tina.