Does anyone know the correct SQL for mySQL to create unique key fields for tables. Everything I have tried doesn't work and my mySQL book of 500 pages only dedicates 2 paragraphs to the subject with zero examples.
My table would look like this:
create table test(username varchar(10) primary key, password varchar(10),
questionone INT,
questiontwo INT,
questionthree INT,
questionfour INT);
I would like to make the question fields unique. You can just write unique next to the INT, it doesn't work. Neither did this.
create table TEST (
username varchar(255) PRIMARY KEY,
name2 varchar(255),
questionone INT not null,
questiontwo INT not null,
UNIQUE ques_one_idx (questionone),
UNIQUE ques_two_idx (questiontwo)
);
Thanks.
My table would look like this:
create table test(username varchar(10) primary key, password varchar(10),
questionone INT,
questiontwo INT,
questionthree INT,
questionfour INT);
I would like to make the question fields unique. You can just write unique next to the INT, it doesn't work. Neither did this.
create table TEST (
username varchar(255) PRIMARY KEY,
name2 varchar(255),
questionone INT not null,
questiontwo INT not null,
UNIQUE ques_one_idx (questionone),
UNIQUE ques_two_idx (questiontwo)
);
Thanks.