Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

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

like image 855
moses toh Avatar asked May 25 '16 04:05

moses toh


People also ask

How CREATE TABLE as SELECT works?

In a table resulting from CREATE TABLE ... SELECT , columns named only in the CREATE TABLE part come first. Columns named in both parts or only in the SELECT part come after that. The data type of SELECT columns can be overridden by also specifying the column in the CREATE TABLE part.

How do I group by a specific column in SQL?

Syntax: SELECT column1, function_name(column2) FROM table_name WHERE condition GROUP BY column1, column2 ORDER BY column1, column2; function_name: Name of the function used for example, SUM() , AVG(). table_name: Name of the table.

Can we put space name in the table?

Blanks spaces are restricted in the naming convention of the database object's name and column name of the table.


1 Answers

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
like image 97
sonique Avatar answered Sep 27 '22 22:09

sonique