我正在使用MySQL创建内容管理系统应用程序。我的SQL脚本有错误。错误提示:
insert into blogposts (title, lede, content, tag, author, created_at) values
(
'Title of a longer featured blog post',
'Multiple lines of text that form the lede, informing new readers quickly and efficiently about what’s most interesting in this post’s contents.',
'This blog post shows a few different types of content that’s supported and styled with Bootstrap. Basic typography, images, and code are all supported.',
'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.',
'World',
'Mark',
'1553437967526'
)
#1136 - Column count doesn't match value count at row 1.
我知道questions with the same title,但是我无法使用他们的答案来解决此问题。这是我的整个SQL脚本:
start transaction;
CREATE DATABASE content_management_system;
use content_management_system;
create table blogposts(
id integer unsigned not null auto_increment,
title varchar(512) not null,
lede varchar(512) not null,
content varchar(10000) not null,
tag varchar(512) not null,
author varchar(512) not null,
created_at integer unsigned not null,
PRIMARY KEY (id)
);
insert into blogposts (title, lede, content, tag, author, created_at) values
('Title of a longer featured blog post',
'Multiple lines of text that form the lede, informing new readers quickly and efficiently about what’s most interesting in this post’s contents.',
'This blog post shows a few different types of content that’s supported and styled with Bootstrap. Basic typography, images, and code are all supported.', 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.',
'World',
'Mark',
'1553437967526');
create table website(
id integer unsigned not null auto_increment,
title varchar(256) not null,
about varchar(256) not null,
topId integer unsigned not null,
leftId integer unsigned not null,
rightId integer unsigned not null,
PRIMARY KEY(id)
);
insert into website (title, about, topId, leftIf, rightId) values
('CMS Demo',
'Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.'
1,
2,
3);
create table users(
id integer unsigned not null auto_increment,
username varchar(256) not null,
password varchar(256) not null
);
insert into users (username, password) values
('Mark', 'fubar');
commit;
答案 0 :(得分:1)
在insert into blogposts (title, lede, content, tag, author, created_at)
中定义了6个变量,但在INSERT中给出了7个参数。这就是计数不匹配的原因。
答案 1 :(得分:0)
这是一段有效的SQL脚本:
insert into blogposts (title, lede, content, tag, author, created_at) values
('Title of a longer featured blog post',
'Multiple lines of text that form the lede, informing new readers quickly and efficiently about what’s most interesting in this post’s contents.',
'This blog post shows a few different types of content that’s supported and styled with Bootstrap. Basic typography, images, and code are all supported.',
'World',
'Mark',
1553437967526);