Stephane Lemonnier
Stephane Lemonnier

Reputation: 13

MySQL "simple" error understanding

i have a very simple request :

SELECT * FROM players;

which works and show a list of "players". Now if i do the exact same request on my table named "groups" i get a syntax error

SELECT * FROM groups;

Error Code: 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 'groups' at line 1 0.000 sec

If I do :

SELECT * FROM mydb.groups;

It works and if I do :

SELECT * FROM `groups`;

It works too.

Upvotes: 1

Views: 57

Answers (2)

Bjoern Rennhak
Bjoern Rennhak

Reputation: 6936

Error Code: 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 'groups' at line 1 0.000 sec

MySQL Documentation lists GROUP and GROUPS as reserved keywords, hence your query fails.

Upvotes: 1

A. Colonna
A. Colonna

Reputation: 872

GROUPS is a reserved keywords (GROUPS (R) added in 8.0.2 (reserved)) :

https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-G

Upvotes: 2

Related Questions