I need to insert
multiple rows for current column in a table.
sql
insert into pa
(cd)
values
((select 'SU' from pa where pa_id = 101))
;
What is the correct syntax? Getting error, cannot insert null value.
insert into pa (cd)
select 'SU'
from pa
where pa_id = 101
I suspect that you want an update
instead:
update pa
set cd = 'SU'
where pa_id = 101;
insert
inserts a new row. All the columns not included in the insert
are set to NULL
-- which is no doubt causing your error.
You seem to want to change the value in an existing row; update
does that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.