这是我的表定义:
CREATE TABLE IF NOT EXISTS `sms_data_updated` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_sms_received` int(10) unsigned DEFAULT NULL,
`sender_name` varchar(50) NOT NULL,
`sender_number` char(14) NOT NULL,
`key_word` varchar(20) NOT NULL,
`message_content` varchar(160) NOT NULL,
`date_received` datetime NOT NULL,
`date_inserted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`categories` varchar(100) NOT NULL,
`Division` varchar(30) NOT NULL,
`location_name` varchar(80) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
使用以下INSERT语句时:
INSERT INTO sms_data_updated (id_sms_received, sender_name, sender_number, key_word, message_content, date_received, Division, location_name)
VALUES (1,Shahriar Khondokar,+1726740333,,This is message content1. I need help1.,2012-10-16 10:11:09,Barisal,Borishal)
我收到以下错误消息:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'Khondokar,+8801726740333,,This is message content1. I need help1.,2012-10-16 10:' at line 1
知道为什么吗?
答案 0 :(得分:3)
字符串值必须用单引号
换行VALUES(1,'Shahriar Khondokar','+172674033','This is message content1.',...)
答案 1 :(得分:1)
看起来你在location_name
之后有一个悬挂的逗号。
答案 2 :(得分:1)
像Shahriar Khondoka这样的字符串需要引用它。像这样:
INSERT INTO sms_data_updated (id_sms_received, sender_name, sender_number, key_word, message_content, date_received, Division, location_name, Latitude, Longitude)
VALUES (1,'Shahriar Khondokar',rest of columns...)
答案 3 :(得分:1)
您在查询中插入的行数具有不同数量的值。这可能会导致问题。