首次插入时,出现以下错误:


  结果由多于一行组成。


当我第二次尝试插入记录时,它给我错误消息:duplicate entry

SQL:

INSERT INTO `master_user` (`name`,`user_name`,`email`,`password`,`system_name_of_friend`,`system_no_of_friend`,`registered_from_site`,`registered_on`,`is_existing_user`)
VALUES ('FirstName LastName','username','[email protected]','8c71eede42e38709e9e836021b0b9b9b','','','site','','1')


任何帮助将不胜感激,下面是表结构,将有助于跟踪此问题。

CREATE TABLE IF NOT EXISTS `master_user` (
  `master_user_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `user_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `system_name_of_friend` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `system_no_of_friend` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `registered_from_ip` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `registered_from_site` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `registered_on` datetime DEFAULT NULL,
  `is_existing_user` bit(1) NOT NULL DEFAULT b'0',
  PRIMARY KEY (`master_user_id`),
  UNIQUE KEY `ukMasterUser_email` (`email`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1293 ;

最佳答案

您应删除'包围位值的内容,否则它将被解释为一个字符,该字符超过1位。并且也将日期设置为null,而不是插入''

INSERT INTO `master_user` (`name`,`user_name`,`email`,`password`,`system_name_of_friend`,`system_no_of_friend`,`registered_from_site`,`registered_on`,`is_existing_user`)
VALUES ('FirstName LastName','username','[email protected]','8c71eede42e38709e9e836021b0b9b9b','','','site',null,1);


SQLFiddle:http://sqlfiddle.com/#!2/eda2ff

10-08 04:31