日期:2014-05-16  浏览次数:20560 次

MERGE into (用法笔记)

?MERGE INTO trackedVehicleBus t

? ? USING (SELECT tt.* FROM trackedVehicleBus tt WHERE tt.tracktype = 2) tw

? ? ON (t.tracktype = tw.tracktype)

? ? WHEN MATCHED THEN

? ? ? UPDATE SET t.rolename = 'upad3te'

? ? WHEN NOT MATCHED THEN

? ? ? INSERT

? ? ? VALUES

? ? ? ? ('11', '22', 'insert', 'a$f$fG$ff', 1, '02:00', '05:00', 2);

? ??

? ? MERGE INTO trackedVehicleBus t

? ? USING (select count(*) co

? ? ? ? ? ? ?from trackedVehicleBus bs

? ? ? ? ? ? where bs.tracktype = 2) tw

? ? ON (tw.co <> 0)

? ? WHEN MATCHED THEN

? ? ? UPDATE SET t.rolename = 'upad3te'

? ? WHEN NOT MATCHED THEN

? ? ? INSERT

? ? ? VALUES

? ? ? ? ('11', '22', 'insert', 'a$f$fG$ff', 1, '02:00', '05:00', 2);

? ??