0

I have in this query an syntax error:

$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
)

Anyone can help me to resolve this error?

EDIT: The error is

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

2
  • what was then error? Commented Jun 25, 2015 at 10:10
  • Try sth like type ENUM ('a', 'b', 'c'),... Commented Jun 25, 2015 at 10:11

1 Answer 1

3

ENUM needs enumeration values to be supplied as string literals something as

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.