日期:2014-05-17  浏览次数:20715 次

求个查询语句!!!
例如  我有两个表table1和table2   ID是主键
table1:
ID      A     B    C   D
...
table2:
ID     A      B     C    D 
1       1      1     3     2
2       2      1     4     3
3       3      1     5     4
4       4      1     6     5
5       5      3     7     6
...
我想做的是把 table2中B字段为1的数据 插入到table1中(table1的字段B中的字段插入一个固定的值  如3)
结果如下:
table1:
ID      A     B    C   D
...
10      1     3    3    2
11      2     3    4    3
12      3     3    5    4
13      4     3    6    5
求sql语句!!!!


------解决方案--------------------
insert into table1 select id,a,'3',c,d from table2 where table2.b=1????????????
------解决方案--------------------
insert into table1
  select (select max(id) + rownum from table1), a, '3', c, d
    from table2
   where table2.b = 1;
------解决方案--------------------
update  table1 a
set a.b=3