簡體   English   中英

插入多行有條件

[英]insert multiple rows with condition

我需要為表中的當前列insert多行。

sql

insert into pa
(cd)
values
((select 'SU' from pa where pa_id = 101))
 ;

什么是正確的語法? 獲取錯誤,無法插入空值。

insert into pa (cd)
select 'SU' 
from pa
where pa_id = 101

我懷疑你想要update

update pa
    set cd = 'SU'
    where pa_id = 101;

insert插入一個新行。 insert中未包含的所有列都設置為NULL - 這無疑會導致您的錯誤。

您似乎想更改現有行中的值; update這樣做的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM