J
J
JackShcherbakov2018-03-20 00:18:19
MySQL
JackShcherbakov, 2018-03-20 00:18:19

Where is the error in the SQL command to create the table?

Error while executing the script:

CREATE TABLE users (
    id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    login NOT NULL PRIMARY KEY VARCHAR(255), 
    password NOT NULL PRIMARY KEY VARCHAR(255)
);

ERROR 1064 (42000): 
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 'NOT NULL PRIMARY KEY VARCHAR(255)
, password NOT NULL PRIMARY KEY VARCHAR(255))' at line 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-03-20
@0xD34F

First - not NOT NULL VARCHAR, but VARCHAR NOT NULL. Second, there can only be one primary key.
I think you meant this:

CREATE TABLE users (
    id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    login VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question