debug sql语法,错误#1064

时间:2012-11-09 06:35:56

标签: mysql syntax phpmyadmin

我在共享主机中使用phpmyadmin中的以下脚本:

USE newmakerting
CREATE TABLE `nemarketing_registration`.`users` (

`id` INT NOT NULL AUTO_INCREMENT ,
`email` VARCHAR( 256 ) ,
`firstName` VARCHAR( 256 ) ,
`lastName` VARCHAR( 256 ) ,
`profession` VARCHAR( 256 ) ,
`company` VARCHAR( 256 ) ,
`country` VARCHAR( 256 ) ,
`ticketNumber` VARCHAR( 256 ) ,
`jobArea` VARCHAR( 256 ) ,
`networkingPeople` VARCHAR( 256 ) ,
`topics_networking` VARCHAR( 256 ) ,
`topics_research` VARCHAR( 256 ) ,
`topics_tochat` VARCHAR( 256 ) ,
`last_book` VARCHAR( 256 ) ,
 PRIMARY KEY ( `id` ) 
 ) CHARACTER SET utf8;

但是我收到了以下错误:

# 1064 - You have an error in your SQL syntax; check the handbook That corresponds

to your MySQL server version for the right syntax to use near 'CREATE TABLE `` 

nemarketing_registration. `Users` (`id` INT NOT NULL AUTO_INC 'at line 2 

2 个答案:

答案 0 :(得分:0)

USE newmakerting之后添加分隔符,尝试

USE newmakerting;         -- << this one

CREATE TABLE `nemarketing_registration`.`users` 
(
`id` INT NOT NULL AUTO_INCREMENT ,
`email` VARCHAR( 256 ) ,
`firstName` VARCHAR( 256 ) ,
`lastName` VARCHAR( 256 ) ,
`profession` VARCHAR( 256 ) ,
`company` VARCHAR( 256 ) ,
`country` VARCHAR( 256 ) ,
`ticketNumber` VARCHAR( 256 ) ,
`jobArea` VARCHAR( 256 ) ,
`networkingPeople` VARCHAR( 256 ) ,
`topics_networking` VARCHAR( 256 ) ,
`topics_research` VARCHAR( 256 ) ,
`topics_tochat` VARCHAR( 256 ) ,
`last_book` VARCHAR( 256 ) ,
 PRIMARY KEY ( `id` ) 
 ) CHARACTER SET utf8;

答案 1 :(得分:0)

Please change as per below :
1) "USE newmakerting" => "USE newmakerting;"
   Here semicolon is missing.
2) "CREATE TABLE `nemarketing_registration`.`users`"  =>
    "CREATE TABLE `newmakerting`.`users`"
    Here database name is wrong .
ex:
USE newmakerting;
CREATE TABLE `newmakerting`.`users` (
`id` INT NOT NULL AUTO_INCREMENT ,
`email` VARCHAR( 256 ) ,
`firstName` VARCHAR( 256 ) ,
`lastName` VARCHAR( 256 ) ,
`profession` VARCHAR( 256 ) ,
`company` VARCHAR( 256 ) ,
`country` VARCHAR( 256 ) ,
`ticketNumber` VARCHAR( 256 ) ,
`jobArea` VARCHAR( 256 ) ,
`networkingPeople` VARCHAR( 256 ) ,
`topics_networking` VARCHAR( 256 ) ,
`topics_research` VARCHAR( 256 ) ,
`topics_tochat` VARCHAR( 256 ) ,
`last_book` VARCHAR( 256 ) ,
 PRIMARY KEY ( `id` ) 
 ) CHARACTER SET utf8;