举个例子,两个table都是如下创建的:
create table table1
(
a int not null, b int not null
)
create table table2
(
a int not null, b int not null
)
table1有一些数据,现在我想select * from table1 where a > 2,然后将这些行插入table2,请问该如何编程实现?
请写个较短的程序实现它

解决方案 »

  1.   

    如果保证两个表的字段相同的话,可以直接实现的;用子查询可以实现:insert into table2 values(select * from table1 where a > 2)试试这条SQL语句可行不?应该可以解决问题的
      

  2.   

    select table1.a,table1.b into table2 from table1 where where a > 2
      

  3.   

    具体要看你用的什么数据库了,insert into table2 values(select * from table1 where a > 2)应该是没问题的。
      

  4.   


    select * into table2 from table1 where a > 2