Danial Kosarifa
Danial Kosarifa

Reputation: 1074

I keep getting 1064 error in phpmyadmin

I am trying to create a table in phpmyadmin with the following

SQL : 

CREATE TABLE `umOrder`.`Bill` (
    `Id` INT(5) NOT NULL AUTO_INCREMENT ,
    `userID` VARCHAR(255) NOT NULL ,
    `product` VARCHAR(255) NOT NULL ,
    `quantity` INT(3) NOT NULL ,
    `price` DOUBLE(5) NOT NULL , 
    `date` VARCHAR(255) NOT NULL ,
    PRIMARY KEY (`Id`(5))
  ) ENGINE = MEMORY;

But keep getting this error :

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 ') NOT NULL , date VARCHAR(255) NOT NULL , PRIMARY KEY (Id(5))) ENGINE =' at line 1

I don't really understand what the error mean ? any Idea ?

Upvotes: 0

Views: 2508

Answers (3)

William Hou
William Hou

Reputation: 1771

"double" doesn't take a length argument, just like Gordon Linoff said above.

I got almost exactly the same problem.

Then I got rid of the length for double, and everything is fine now.

Upvotes: 0

Daerik
Daerik

Reputation: 4277

You'll want to assign the decimal for the double:

CREATE TABLE `umOrder`.`Bill` (
    `Id` INT (5) NOT NULL AUTO_INCREMENT,
    `userID` VARCHAR (255) NOT NULL,
    `product` VARCHAR (255) NOT NULL,
    `quantity` INT (3) NOT NULL,
    `price` DOUBLE (5,2) NOT NULL,
    `date` VARCHAR (255) NOT NULL,
    PRIMARY KEY (`Id`)
) ENGINE = MEMORY;

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269503

The key(id(5)) is suspect. But you have another error as well: double doesn't take a length argument.

The following should work:

CREATE TABLE `Bill` (
    `Id` INT(5) NOT NULL AUTO_INCREMENT ,
    `userID` VARCHAR(255) NOT NULL ,
    `product` VARCHAR(255) NOT NULL ,
    `quantity` INT(3) NOT NULL ,
    `price` DOUBLE NOT NULL , 
    `date` VARCHAR(255) NOT NULL ,
    PRIMARY KEY (`Id`)
  ) ENGINE = MEMORY;

Here is a SQL Fiddle.

Note: I don't think it is helpful to put length arguments after numeric types (other than decimal/numeric). You might want to consider removing all of them.

Upvotes: 2

Related Questions