Reputation: 21
1064 - 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 'enum('m''f'), secretquestion
varchar(255) NOT NULL, answer
varch' at line 6
create table user_login (
`username` varchar(20) NOT NULL UNIQUE,
`emailid` varchar(30) NOT NULL,
`password` varchar(30) NOT NULL,
`retypepassword` varchar(30) NOT NULL,
`gender` char(1) enum('m''f'),
`secretquestion` varchar(255) NOT NULL,
`answer` varchar(50) NOT NULL,
`mobileno` char(10)NOT NULL,
`dob`DATE NOT NULL,
`occupation` varchar(30)NOT NULL,
`city` varchar(50) NOT NULL,
`state` varchar(50) NOT NULL,
`pincode` char(6) NOT NULL,
`checkbox` tinyint(1));
Upvotes: 2
Views: 28624
Reputation: 31
You shouldn't use a CHAR
datatype with an ENUM
datatype because they are both a string datatype, it's like you're using a CHAR
string datatype with a VARCHAR
or TEXT
which is not true.
You can use
Gender ENUM('M', 'F'),
Upvotes: 3
Reputation: 31
"CREATE TABLE tbl_users (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50) NOT NULL,
password VARCHAR(30) NOT NULL,
mobile_no CHAR(20) NOT NULL,
###gender ENUM('m','f') NOT NULL,###
country VARCHAR(50) NOT NULL,
state VARCHAR(50) NOT NULL,
city VARCHAR(50) NOT NULL,
pin CHAR(10),
address VARCHAR(50) NOT NULL,
reg_date TIMESTAMP
)";
Upvotes: 3
Reputation: 13484
An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time.
use gender char(1) enum('m','f')
create table user_login (
`username` varchar(20) NOT NULL UNIQUE,
`emailid` varchar(30) NOT NULL,
`password` varchar(30) NOT NULL,
`retypepassword` varchar(30) NOT NULL,
`gender` char(1) enum('m','f'),
`secretquestion` varchar(255) NOT NULL,
`answer` varchar(50) NOT NULL,
`mobileno` char(10)NOT NULL,
`dob`DATE NOT NULL,
`occupation` varchar(30)NOT NULL,
`city` varchar(50) NOT NULL,
`state` varchar(50) NOT NULL,
`pincode` char(6) NOT NULL,
`checkbox` tinyint(1));
Upvotes: 4