Fix MySQL Database Error #1064?


The Database Error #1064 may occur due to incorrect syntax. For example, let’s say we are creating the below table −

mysql> create table DemoTable
   (
      UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
      UserName varchar(100),
      UserAge int,
      UserAddress varchar(200),
      UserCountryName varchar(100) ,
      isMarried boolean,
   );

This will produce the following output i.e. error −

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 ')' at line 10

To get rid of the above error, you need to remove last comma(,). The query is as follows to remove the error −

mysql> create table DemoTable
   (
      UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
      UserName varchar(100),
      UserAge int,
      UserAddress varchar(200),
      UserCountryName varchar(100),
      isMarried boolean
   );
Query OK, 0 rows affected (1.04 sec)

Updated on: 22-Aug-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements