0
CREATE TABLE IF NOT EXISTS 'users' (   
'id' int(11) NOT NULL AUTO_INCREMENT,   
'username' varchar(255) NOT NULL,   
'first_name' varchar(255) NOT NULL,   
'last_name' varchar(255) NOT NULL,   
'email' varchar(255) NOT NULL,   
'password' varchar(32) NOT NULL,   
'sign_up_date' date NOT NULL,   
'activated' enum('0','1') NOT NULL,   
PRIMARY KEY ('id')  
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; 

MySQL said: Documentation #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 ''users' ( 'id' int(11) NOT NULL AUTO_INCREMENT, 'username' varchar(255) NO' at line 1

Venkatesh Panabaka
  • 2,064
  • 4
  • 19
  • 27
Mohammad Usman
  • 39
  • 1
  • 2
  • 9
  • 1
    get rid off single quotes on table and column names. – Abhik Chakraborty Jul 21 '15 at 10:26
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – miken32 Dec 12 '20 at 22:10

2 Answers2

2

I think these SQL useful to you. Just replace ' with `.

CREATE TABLE IF NOT EXISTS `users` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(255) NOT NULL,
    `first_name` VARCHAR(255) NOT NULL,
    `last_name` VARCHAR(255) NOT NULL,
    `email` VARCHAR(255) NOT NULL,
    `password` VARCHAR(32) NOT NULL,
    `sign_up_date` DATE NOT NULL,
    `activated` ENUM('0','1') NOT NULL,
    PRIMARY KEY (id))
    ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Thank you.

Venkatesh Panabaka
  • 2,064
  • 4
  • 19
  • 27
  • MySQL returned an empty result set (i.e. zero rows). (Query took 0.5148 seconds.) CREATE TABLE IF NOT EXISTS `users` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `username` VARCHAR(255) NOT NULL, `first_name` VARCHAR(255) NOT NULL, `last_name` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL, `password` VARCHAR(32) NOT NULL, `sign_up_date` DATE NOT NULL, `activated` ENUM('0','1') NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 – Mohammad Usman Jul 21 '15 at 10:53
  • what does it mean by empty result set? – Mohammad Usman Jul 21 '15 at 10:54
  • Sorry, I just like a warning message don't worry about that message. if you refresh the database and see table is available or not. You satisfied my answer and give a tick mark and up vote please. – Venkatesh Panabaka Jul 21 '15 at 11:08
-1

CREATE TABLE IF NOT EXISTS announcement ( id int NOT NULL AUTO_INCREMENT, title varchar(255) DEFAULT NULL, description text NOT NULL, date date NOT NULL, category varchar(100) NOT NULL, thumbnail varchar(255) NOT NULL, schoolid varchar(255) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

  • Please use proper formatting on your answer, and provide some commentary on how it improves the accepted 5 year old answer. – miken32 Dec 12 '20 at 22:09