moses toh moses toh - 6 months ago 5
MySQL Question

How to choose a table that have the table name : "group"?

I have a table. Name of the table is "group"

I run query like this :

SELECT * FROM GROUP


There exist error like this :

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 'group
LIMIT 0, 1000' at line 1


Any solution to solve my problem?

Thank you

Answer

use backquote :

SELECT * FROM `GROUP`

you can also alias your table name for later use in WHERE clause for instance:

SELECT * FROM `GROUP` g WHERE g.id = 1
Comments