0

I need some help, I'm getting error 1064 when I try to insert data into a table!

INSERT INTO areas (Nombre) values ('area 1');

Table:

CREATE TABLE Areas (
    Id INT PRIMARY KEY AUTO_INCREMENT,
    Nombre VARCHAR(100) UNIQUE NOT NULL
);

What's wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Mauro
  • 11
  • Table name in insert query. Changed `areas` to `Areas`. – Pankaj K Jun 26 '15 at 04:51
  • Please update your question with the OS you are using (Windows or Linux). – Tim Biegeleisen Jun 26 '15 at 04:55
  • I think he is using Linux. – Pankaj K Jun 26 '15 at 04:57
  • 1
    Your error message is inconsistent with what you have shown us in your question. Is there any other information you might be leaving out which could explain the `1064` error? – Tim Biegeleisen Jun 26 '15 at 05:07
  • 1
    The INSERT statement is fine, as long as the CREATE TABLE is run first. A duplicate key error would be `Error code: 1062`, a table doesn't exist error would be `Error code: 1146`. But you report that error code `1064` is being returned. That error usually includes a portion of the statement text, identifying the point in the statement text where MySQL detects syntax error. In its current form, this question is unanswerable. (You've not identified which client you are using to submit SQL to the database.) – spencer7593 Jun 26 '15 at 05:14
  • @spencer7593 No need to vote everyone down across the board, as the owner of the question may return to give us more information. But yeah, it feels pretty good to vote people down. – Tim Biegeleisen Jun 26 '15 at 05:21

2 Answers2

-1

It's because you used areas instead of Areas.

-1

Your server configuration seems case sensitive so areas and Areas will be 2 tables.

try below-

INSERT INTO Areas (Nombre) VALUES ('area 1');

If you want to take care it then update below variable in your my.cnf or my.ini file.

lower_case_table_names = 1
Zafar Malik
  • 6,734
  • 2
  • 19
  • 30