I wanted to execute the following statement to create a table for storing various details .Here name of movies will store there “Ratings in integer value” Please help me solve this issue
CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
website VARCHAR,
aboutyou VARCHAR,
gender VARCHAR(50) NOT NULL,
avengers INT NOT NULL,
inception INT NOT NULL,
godfather INT NOT NULL,
mrrobot INT NOT NULL,
xfiles INT NOT NULL,
friends INT NOT NULL
);
I get error from phpmyadmin as:
MySQL said: Documentation
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘aboutyou VARCHAR,
gender VARCHAR(50) NOT NULL,
avengers INT NOT’ at line 6
2
Answers
Give them length as you did with gender and it will work.
I guess that the error is due to the fact that you do not provide the VARIABLE for the length of the string. You specify only that you want to use VARCHAR as a data type for the columns website and aboutyou. But the correct form is VARCHAR(n), where n the number of characters you want your string to be. I tried to implement it myself, and when I gave a number enclosed in parentheses, it worked perfectly.
An example, try:
I hope that helps and answers your question.
Good luck with your project!