简体   繁体   中英

How to insert content of multiple columns into a new column in sql?

I want to combine the content of two columns and insert it into a new column.

But it does not work. Example:

create table car(
   id bigint NOT NULL,
   manufacture character varying(255),
   number character varying(255),
   result character varying(255)
)

insert into car (result)
select concat(manufacture, ' ', number) from car

Result:

ERROR:  NULL-Value in column „id“ error Not-Null-Constraint
DETAIL:  Failed line contains (null, null, null, bmw 123).

How can I just update the specific row, and leave all other values as it is?

update car set result = concat(manufacture, ' ', number)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM