首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

求个查询话语!

2013-07-08 
求个查询语句!!!例如我有两个表table1和table2ID是主键table1:IDABCD...table2:IDABCD 111322214333154441

求个查询语句!!!
例如  我有两个表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


where a.id=(select id from table2
where b=1);
commit;

热点排行