我正在尝试运行以下查询:
"insert into visits set source = 'http://google.com' and country = 'en' and ref = '1234567890';"
查询看起来不错,它会打印一条警告:
1 row(s) affected, 2 warning(s): 1364 Field 'country' doesn't have a default value 1292 Truncated incorrect DOUBLE value: 'http://google.com'
并且信息没有按预期存储:
id , ref , bnid, source, country
'5', NULL, NULL, '0' , ''
如果我运行像这样的普通语法:
insert into visits (source,country,ref) values('http://google.com','en','1234567890');
我得到了预期的结果:
'6', '1234567890', NULL, 'http://google.com', 'en'
第一个语法(插入集)在以前的服务器中有效。现在我换成了一个带有 cpanel 的,但它没有。这是我这周第二次在两个不同的 VPS 和 cpanel 中遇到这个问题,所以我猜它应该是版本号或 mysql 配置。
Mysql版本:5.1.63-cll
表:
CREATE TABLE `visits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ref` varchar(64) DEFAULT NULL,
`bnid` int(11) DEFAULT NULL,
`source` varchar(256) DEFAULT NULL,
`country` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
Có giúp gì không?
从插入查询中删除'and'
insert into visits set source = 'http://google.com' , country = 'en' , ref = '1234567890'
Tôi là một lập trình viên xuất sắc, rất giỏi!