您的位置:首页 > 其它

从一个或几个table中获取数据插入到另一个table中

2010-08-31 17:03 288 查看
Table target:

-----------------------------------------------

ID char(32) PK

description varchar(100) null

value var not null

update_time date not null

Table sourceA

----------------------------------------------

sourceID char(32) PK

flag char(1) not null

Table sourceB

----------------------------------------------

sourceID char(32) PK

value varchar(1) not null

insert into target(

ID,

description,

value,

update_time

)

select

s1.sourceID,

case when s1.flat = 'Y' then 'active'

when s1.flat = 'N' then 'deactive'

end,

s2.value,

current_timestamp

from sourceA s1, sourceB s2;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: