2015-06-25 93 views
0

我有一個語法錯誤:SQL語法錯誤,當我在此查詢執行查詢

$sql = "CREATE TABLE cb (
id INT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
p VARCHAR(255) NOT NULL, 
t1 VARCHAR(255) NOT NULL, 
t2 VARCHAR(255) NOT NULL, 
type ENUM, 
title VARCHAR(255) NOT NULL 
) 

任何人都可以幫我解決這個問題?

編輯:該錯誤是

Error creating table: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' title VARCHAR(255) NOT NULL)' at line 6

+0

當時被錯誤地提供需要枚舉值? – Madhivanan

+0

嘗試......類似ENUM('a','b','c'),...' –

+0

什麼是錯誤? –

回答

3

ENUM作爲字符串文字的東西作爲

CREATE TABLE cb (
id INT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
p VARCHAR(255) NOT NULL, 
t1 VARCHAR(255) NOT NULL, 
t2 VARCHAR(255) NOT NULL, 
type ENUM('1','2'), 
title VARCHAR(255) NOT NULL 
) 

https://dev.mysql.com/doc/refman/5.0/en/enum.html