Jessica Simcoe
Jessica Simcoe

Reputation: 23

Why do I keep getting INSERT error: has more targets than expression

Me again,

This time I am working on a pg admin sql database and I'm trying to figure out why I am getting this error, I have an insert statement but it keeps saying error: INSERT has more targets than expression, I don't really know why I am getting this error so I don't really know what steps to take to fix this.

INSERT INTO automobiles(id, make, model, year, owner, msrp, purchase_date) VALUES(
1,
'Ferarri'
'F40'
'1987'
''
'1,690,000'
'');

The above is the statement I have inserted.

ERROR:  INSERT has more target columns than expressions
LINE 23: INSERT INTO automobiles(id, make, model, year, owner, msrp, ...
                                           ^
********** Error **********

ERROR: INSERT has more target columns than expressions
SQL state: 42601
Character: 401

This is the error and the error is saying its around model

Also I'm using pg admin

Thanks for the help!

Upvotes: 0

Views: 59

Answers (1)

SE1986
SE1986

Reputation: 2740

You need to comma separate the values being inserted

INSERT INTO automobiles
(
   id,
   make,
   model,
   year,
   owner,
   msrp,
   purchase_date
)
VALUES
(
   1,
   'Ferarri',
   'F40',
   '1987',
   '',
   '1,690,000',
   ''
);

Upvotes: 1

Related Questions