I have the following query:
CREATE TABLE UserDetails (
sno INT UNSIGNED AUTO_INCREMENT,
username VARCHAR(20) NOT NULL,
location VARCHAR(20) NOT NULL,
country VARCHAR(20) NOT NULL,
UNIQUE KEY(username)
);
It is giving the following error:
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
I want to set sno to auto increment and username to UNIQUE AND NOT NULL.
What am I doing wrong?
snoneeds to be aPRIMARY KEYif you want it to be auto incremented. Replace:with