我的SQL语法不正确

时间:2014-12-04 12:23:54

标签: mysql sql

我在' adminlogin'附近收到语法错误。对于以下代码

它的错误是什么?

CREATE TABLE IF NOT EXISTS "adminlogin" (
  `id` intiger (11) NOT NULL AUTO_INCREMENT,
  `adminusername` varchar(50) COLLATE latin1_general_ci DEFAULT NULL,
  `adminpassword` varchar(50) COLLATE latin1_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;

2 个答案:

答案 0 :(得分:2)

使用tick(`)代替双引号("")

 CREATE TABLE IF NOT EXISTS `adminlogin` (
`id`  integer(11) NOT NULL AUTO_INCREMENT ,
`adminusername`  VARCHAR (50) COLLATE latin1_general_ci DEFAULT NULL,
`adminpassword`  VARCHAR (50) COLLATE latin1_general_ci DEFAULT NULL ,
 PRIMARY KEY (`id`)
)ENGINE = MyISAM DEFAULT CHARSET = latin1 COLLATE = latin1_general_ci AUTO_INCREMENT = 3;

您也可以使用这种方式,SET SQL_MODE = ANSI_QUOTES;

http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_ansi_quotes

ANSI_QUOTES

Treat “"” as an identifier quote character (like the “`” quote character) and not as a
string quote character. You can still use “`” to quote identifiers with this mode 
enabled. With ANSI_QUOTES enabled, you cannot use double quotation marks to quote 
literal strings, because it is interpreted as an identifier.

答案 1 :(得分:1)

将“”更改为“”并将“整数”改为“整数”。它应该可以正常工作。