Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql Error 1064 - Created using MySQL WorkBench

I created this using MySQL WorkBench

CREATE  TABLE IF NOT EXISTS `bakasura_new`.`cities` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(255) NOT NULL COMMENT 'City Name' ,
  `short_name` VARCHAR(255) NOT NULL COMMENT 'Short Name' ,
  `country_id` INT(11) UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_cities_countries` (`country_id` ASC) ,
ENGINE = InnoDB;

I am getting this error

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 '= InnoDB' at line 8

like image 828
Harsha M V Avatar asked Apr 21 '26 20:04

Harsha M V


2 Answers

You have a dangling comma here:

INDEX `fk_cities_countries` (`country_id` ASC) ,

And you also have a missing parenthesis at the end:

CREATE  TABLE IF NOT EXISTS `bakasura_new`.`cities` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(255) NOT NULL COMMENT 'City Name' ,
  `short_name` VARCHAR(255) NOT NULL COMMENT 'Short Name' ,
  `country_id` INT(11) UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_cities_countries` (`country_id` ASC)
) ENGINE = InnoDB;
like image 107
Daniel Vassallo Avatar answered Apr 24 '26 12:04

Daniel Vassallo


There is a ) missing at the end of the last )

INDEX `fk_cities_countries` (`country_id` ASC) )
like image 33
DrColossos Avatar answered Apr 24 '26 11:04

DrColossos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!