mysql 错误;错误代码:1136。列计数与第 1 行的值计数不匹配
mysql error; Error Code: 1136. Column count doesn't match value count at row 1
我正在学习 MySQL 并且正在尝试创建一个基本的 table。
但我收到此错误:
Error Code: 1136. Column count doesn't match value count at row 1.
查询是
insert into user(username,password,email,created,last_updated) values (
('TEST USERNAME','TEST PASSWORD','Test@test.com',current_timestamp(),current_timestamp()),
('TEST USERNAME 2','TEST PASSWORD 2','Test2@test.com',current_timestamp(),current_timestamp())
);
table 中的列是:
- id
- 用户名
- 密码
- 电子邮件
- 已创建
- last_updated
去掉Values(..)
的括号,即,应该是Values (..), (..)
。
insert into user(username,password,email,created,last_updated)
values
('TEST USERNAME','TEST PASSWORD','Test@test.com',current_timestamp(),current_timestamp()),
('TEST USERNAME 2','TEST PASSWORD 2','Test2@test.com',current_timestamp(),current_timestamp());
从Docs开始,语法是:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
{VALUES | VALUE} (value_list) [, (value_list)] ...
[ON DUPLICATE KEY UPDATE assignment_list]
...
INSERT statements that use VALUES syntax can insert multiple rows. To
do this, include multiple lists of comma-separated column values, with
lists enclosed within parentheses and separated by commas. Example:
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
你的 table 中的列有 id 但你写的时候没有它
insert into user(username,password,email,created,last_updated)
你应该写
insert into user(id,username,password,email,created,last_updated)
我正在学习 MySQL 并且正在尝试创建一个基本的 table。 但我收到此错误:
Error Code: 1136. Column count doesn't match value count at row 1.
查询是
insert into user(username,password,email,created,last_updated) values (
('TEST USERNAME','TEST PASSWORD','Test@test.com',current_timestamp(),current_timestamp()),
('TEST USERNAME 2','TEST PASSWORD 2','Test2@test.com',current_timestamp(),current_timestamp())
);
table 中的列是:
- id
- 用户名
- 密码
- 电子邮件
- 已创建
- last_updated
去掉Values(..)
的括号,即,应该是Values (..), (..)
。
insert into user(username,password,email,created,last_updated)
values
('TEST USERNAME','TEST PASSWORD','Test@test.com',current_timestamp(),current_timestamp()),
('TEST USERNAME 2','TEST PASSWORD 2','Test2@test.com',current_timestamp(),current_timestamp());
从Docs开始,语法是:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_name [, partition_name] ...)] [(col_name [, col_name] ...)] {VALUES | VALUE} (value_list) [, (value_list)] ... [ON DUPLICATE KEY UPDATE assignment_list]
...
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of comma-separated column values, with lists enclosed within parentheses and separated by commas. Example:
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
你的 table 中的列有 id 但你写的时候没有它
insert into user(username,password,email,created,last_updated)
你应该写
insert into user(id,username,password,email,created,last_updated)