'SQL - Column count doesn't match value count at row 1
I am trying to put this into the database. All rows are correct. Each row is also String/Text, except for "Id" which is an auto-incrementing Int value.
I am getting an unexpected error, however, saying Column count doesn't match value count at row 1. What is wrong with the query?
INSERT INTO `world2_main`.`Messages` (
`Id` ,
`ToId` ,
`FromId` ,
`Subject` ,
`Message` ,
`Read` ,
`Original Sender` ,
`Date`
)
VALUES (
NULL, '3611', '156', 'You are so...', 'Cool.', '0', '3611' '1338590308');
Solution 1:[1]
I have also discovered that if you have a trigger on the table you want to insert into and that trigger have another insert statement with un-matching columns and values, it will throw that error "Column count doesn't match value count at row ".
Solution 2:[2]
You may have defined different number of parameters and are probably passing a different number of parameters.
You may have:
INSERT INTO `buyers`(`key1`, `key2` )
VALUES (value1,value2,value3 );
or more number of arguments in INSERT INTO than in the VALUES
Solution 3:[3]
Keep in mind 3 things:
- Number of parameters must match
- auto increment should be taken care of
- (This was my issue) When inserting multiple attributes
don't do this--
insert into agent(eid, ename, email, phone, score) values(
(2, 'b', 'b', 5, 3),
(1, 'a', 'a', 5, 3)
);
You have to do this instead
insert into agent(eid, ename, email, phone, score) values
-> (1, 'a', 'a', 5, 3),
-> (2, 'b', 'b', 5, 3);
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Brian Tompsett - æ±¤èŽ±æ© |
| Solution 2 | Vedha Peri |
| Solution 3 | Ojasv singh |
