-1

这是我的表定义:

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

知道为什么吗?

4

4 回答 4

3

字符串值必须用单引号括起来

VALUES(1,'Shahriar Khondokar','+172674033','This is message content1.',...)
于 2012-10-31T15:59:33.757 回答
1

看起来你在location_name.

于 2012-10-31T15:58:09.210 回答
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...)
于 2012-10-31T15:58:55.297 回答
1

您有不同数量的值作为您在查询中插入的行数。这可能会导致问题。

于 2012-10-31T16:03:00.850 回答