1

When I create a table in my localhost and it says

#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 'NOT NULL, register_date DATETIME NOT NULL, last_login DATETIME NOT NUL' at line 6"

(WampServer v 3.0.6 64bit, Apache 2.4.23 - MySql 5.7.14)

I've already try to change DB engine into InnoDB but the error was still appear.

Here is my Query

CREATE TABLE `inventry`.`users` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(225) NOT NULL,
    `email` VARCHAR(225) NOT NULL,
    `password` VARCHAR(300) NOT NULL,
    `usertype` ENUM(0) NOT NULL,
    `register_date` DATETIME NOT NULL,
    `last_login` DATETIME NOT NULL,
    `notes` VARCHAR(225) NOT NULL,
    PRIMARY KEY(`id`)
) ENGINE = InnoDB;

U P D A T E D******

I want store data in this field. but when i save this it getting error. How can i fix this.?

ENUM

1
  • "An enumeration value must be a quoted string literal," (ENUM). Furthermore: "We strongly recommend that you do not use numbers as enumeration values, because it does not save on storage over the appropriate TINYINT or SMALLINT type, and it is easy to mix up the strings and the underlying number values (which might not be the same) if you quote the ENUM values incorrectly. If you do use a number as an enumeration value, always enclose it in quotation marks. If the quotation marks are omitted, the number is regarded as an index." Commented Jun 19, 2019 at 5:33

2 Answers 2

1

Try below -

CREATE TABLE users(
id INT NOT NULL AUTO_INCREMENT,
username VARCHAR(225) NOT NULL,
email VARCHAR(225) NOT NULL,
password VARCHAR(300) NOT NULL,
usertype ENUM('0') NOT NULL,
register_date DATETIME NOT NULL,
last_login DATETIME NOT NULL,
notes VARCHAR(225) NOT NULL,
primary key (id)
)
Sign up to request clarification or add additional context in comments.

3 Comments

If ENUM(0) is really the only error, then you should be voting to close as a typo, and not answering.
execute his statement, you can see what other errors are!!
1

just put, ENUM values, in quotes

CREATE TABLEinventry.users(
    id INT NOT NULL AUTO_INCREMENT,
    username VARCHAR(225) NOT NULL,
    email VARCHAR(225) NOT NULL,
    password VARCHAR(300) NOT NULL,
    usertype ENUM(**'0'**) NOT NULL,
    register_dateDATETIME NOT NULL,
    last_loginDATETIME NOT NULL,
    notesVARCHAR(225) NOT NULL,
    PRIMARY KEY(id)
) ENGINE = InnoDB;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.