当前位置: 代码迷 >> Informix >> insert into A select first 10 * from B order by rowC解决思路
  详细解决方案

insert into A select first 10 * from B order by rowC解决思路

热度:6319   发布时间:2013-02-26 00:00:00.0
insert into A select first 10 * from B order by rowC
写了一个sql:insert into A select first 10 * from (select * from D where rowD < somevalue order by rowD2) 
两张表的列是一样的.
他说不支持,然后改成:
select * from D where rowD < somevalue order by rowD2 INTO temp SMS_TMP
select first 10 * from SMS_TMP INTO SMS_TMP2...
结果他又说,在这句话里面first是不支持的...
那请问,怎么样才能实现我需要的功能呢?(从D表中取出符合某个条件1,然后按照条件2排序的前N条的数据,插入A表中)
THX

------解决方案--------------------------------------------------------
使用UNLOAD TO 
unload to SMS_TMP.txt select * from select * from A where rowD < somevalue order by rowD2;
load from SMS_TMP.txt insert into B;

------解决方案--------------------------------------------------------
没办法,只有借助其他字段. 比如时间字段. 不大的话,就一条一条的插乐.
当然也可以用load和unload,但也要手动删除一些数据.
  相关解决方案