同时插入和更新

时间:2012-08-10 10:01:23

标签: sql oracle

要将相同的行插入表格,我使用

Insert into table (select * from table where columnA = 'a' and columnB = 'b')

我能在一个sql中插入和更改columnB ='c'吗?

1 个答案:

答案 0 :(得分:3)

是的,只需在select:

中指定值即可
insert into table (ColumnA, ColumnB)
select ColumnA, 'c'
from table
where columnA = 'a' and columnB = 'b'

(如果您有更多列,只需将它们添加到列列表中,然后选择就像ColumnA一样。)