SQL插入错误
问题描述:
我想运行插入到表中,但我的语句不断出错,因为我正在使用像和和他们内部的词。SQL插入错误
如何将这些段落放入数据库中?
INSERT INTO messages (message_title, message_content, from_user,
to_user, date, type, delivered, deleted)
VALUES('Dont forget to configure your profile!',
'Welcome to the Club. The FIRST step to getting started is to set up your
personal profile and your personal goals. You cant improve what you dont
measure! Click on the following link and get your profile set up today.
Set up my profile NOW. If you have any questions please be sure to contact
our support team at [email protected]',
'1', '1', '2014-09-26', '0', '0', '0')
答
我在调查这里您的架构的一些假设,但我要把头伸出所以想后这看看是否有帮助:
http://sqlfiddle.com/#!2/a1471/2
create table messages (message_title varchar(500), message_content varchar(8000), from_user int, to_user int, date datetime, type int, delivered bit, deleted bit);
INSERT INTO messages (message_title, message_content, from_user, to_user, date, type, delivered, deleted)
VALUES(
'Dont forget to configure your profile!',
'Welcome to the Club. The FIRST step to getting started is to set up your personal profile and your personal goals. You cant improve what you dont measure!
Click on the following link and get your profile set up today. Set up my profile NOW
If you have any questions please be sure to contact our support team at [email protected]',
'1',
'1',
'2014-09-26',
'0',
0,
0);
select * from messages
我假设在这里你的删除和传递的列是位字段,当试图插入一个位域为'1'而不是1时,语句出错。正如你可以通过小提琴看到的那样,(只是稍微)修改过的插入语句可以工作。所以希望这会帮助你!
此外,您的其他'1我假设是int列,你不需要引号插入到那些要么。
什么是错误? – 2014-09-26 14:38:45
在字符串值中包含“to”和“and”不会破坏插入语句,请提供您的错误 – Kritner 2014-09-26 14:43:02
消息表的结构是什么? – mpriscella 2014-09-26 14:43:07