1

I have this table and I want to insert values, but it's not working:

MariaDB [worldmap]> show columns from worldmap_table;
+---------------------+------------------+------+-----+---------+----------------+
| Field               | Type             | Null | Key | Default | Extra          |
+---------------------+------------------+------+-----+---------+----------------+
| ID                  | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| servername          | varchar(100)     | NO   |     | NULL    |                |
| trigger_description | varchar(100)     | NO   |     | NULL    |                |
| long                | int(11)          | NO   |     | NULL    |                |
| lat                 | int(11)          | NO   |     | NULL    |                |
| sev1                | int(11)          | NO   |     | NULL    |                |
| sev2                | int(11)          | NO   |     | NULL    |                |
| sev3                | int(11)          | NO   |     | NULL    |                |
| sev4                | int(11)          | NO   |     | NULL    |                |
| sev5                | int(11)          | NO   |     | NULL    |                |
| severity            | int(11)          | NO   |     | NULL    |                |
+---------------------+------------------+------+-----+---------+----------------+
insert into  worldmap_table (servername ,trigger_description, long, lat, sev1, sev2, sev3, sev4, sev5, severity)
    values ("titi", "tata", 3, 2, 4, 5, 7, 8, 5, 9)

But I get this message:

ERROR 1064 (42000): 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 'long, lat, sev1, sev2, sev3, sev4, sev5, severity) values ("titi", "tata", 3, 2' at line 1

1

1 Answer 1

3

Your query needs backticks, and perhaps also the autoincrement field, with value NULL to trigger a new increment:

insert into  worldmap_table (servername ,trigger_description, long, lat, sev1, sev2, sev3, sev4, sev5, severity)
values ("titi", "tata", 3, 2, 4, 5, 7, 8, 5, 9)

should be

insert into  worldmap_table (`ID`, `servername` ,`trigger_description`, `long`, `lat`, `sev1`, `sev2`, `sev3`, `sev4`, `sev5`, `severity`)
values (NULL, "titi", "tata", 3, 2, 4, 5, 7, 8, 5, 9);
Sign up to request clarification or add additional context in comments.

2 Comments

Back-ticks are only required for reserved keywords. (But can be used for all identifiers.)
@jarlh correct, and I would also suggest never using reserved keywords as column names, since they are... reserved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.