簡體   English   中英

MySQL 查詢錯誤 (1064)

[英]MySQL Error in query (1064)

當我在 Phpmyadmin SQL 命令中運行它時,我收到以下 Mysql 錯誤消息。

“查詢錯誤(1064):'IF NOT EXISTS TABLE'o2o_category'('id' int(11) NOT NULL AUTO_INCREMENT, ' at line 2 附近的語法錯誤”

sql如下:

CREATE IF NOT EXISTS TABLE 'o2o_category'(
  'id' int(11) NOT NULL AUTO_INCREMENT,
  'name' VARCHAR(50) NOT NULL DEFAULT '',
  'parent_id' int(10)  NOT NULL DEFAULT 0,
  'listorder' int(8) NOT NULL DEFAULT 0,
  'status' tinyint(1) NOT NULL DEFAULT 0,
  'create_time' int(11) NOT NULL DEFAULT 0,
  'update_time' int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY ('id'),
  KEY parent_id('parent_id')
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

你能給我一些關於什么是錯誤的線索嗎?

謝謝

它應該是CREATE TABLE IF NOT EXISTS而不是CREATE IF NOT EXISTS TABLE

CREATE TABLE IF NOT EXISTS `o2o_category`(
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL DEFAULT '',
    `parent_id` int(10) NOT NULL DEFAULT 0,
    `listorder` int(8) NOT NULL DEFAULT 0,
    `status` tinyint(1) NOT NULL DEFAULT 0,
    `create_time` int(11) NOT NULL DEFAULT 0,
    `update_time` int(11) NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`),
    KEY parent_id(`parent_id`))ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM