Search code examples
mysqlsqlcreate-table

Syntax error in MySQL CREATE TABLE


I want to make a table in phpmyadmin and I am using SQL command for that

CREATE TABLE userdetail(    
detailid INT(255) UNSIGNED AUTO_INCREMENT PRIMARY,
name varchar(255) NOT NULL,
address text,
phone varchar(13) NOT NULL,
email_id varchar(255),
userId int(20) NOT NULL,
reg_date TIMESTAMP
)

I am getting this error:

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 ' name varchar(255) NOT NULL, address text, phone varchar(13) NOT ' at line 2


Solution

  • It should be like this

     CREATE TABLE userdetail(    
        detailid INT(255) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        name varchar(255) NOT NULL,
        address text,
        phone varchar(13) NOT NULL,
        email_id varchar(255),
        userId int(20) NOT NULL,
        reg_date TIMESTAMP);