MERGE
INTO cars2
USING abc
ON (
cars2.vehicleid = abc.vehicleid)
WHEN NOT matched THEN
INSERT
(
cars2.vehicleid,
cars2.brand,
cars2.model,
cars2.vehicle_type,
cars2.fuel_type,
cars2.transmission_type,
cars2.gearbox,
cars2.drive_type,
cars2.vehicle_number,
cars2.price
)
>>VALUES
(
abc.vehicleid,
abc.brand,
abc.model,
abc.vehicle_type,
abc.fuel_type,
abc.transmission_type,
abc.gearbox,
abc.drive_type,
abc.vehicle_number,
abc.price
)
WHERE abc.vehicleid < 1000;
当我执行上面的操作时,它说插入了0行。但实际上它应该插入两行。任何人都可以帮我这个吗?
select VEHICLEID from abc where vehicleid > 1000;
输出: -
VEHICLEID
9977
9978
答案 0 :(得分:1)
认为你需要一个微妙的修改。你的where子句在错误的地方。
MERGE
INTO cars2
USING (
select * from abc WHERE abc.vehicleid < 1000) abc
ON (cars2.vehicleid = abc.vehicleid)
WHEN NOT matched THEN
INSERT
(
cars2.vehicleid,
cars2.brand,
cars2.model,
cars2.vehicle_type,
cars2.fuel_type,
cars2.transmission_type,
cars2.gearbox,
cars2.drive_type,
cars2.vehicle_number,
cars2.price
)
>>VALUES
(
abc.vehicleid,
abc.brand,
abc.model,
abc.vehicle_type,
abc.fuel_type,
abc.transmission_type,
abc.gearbox,
abc.drive_type,
abc.vehicle_number,
abc.price
)