
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL Syntax Error in SELECT Query Using GROUP as Table Name
The group is a reserved keyword, you can’t use it as table name. Therefore, on using it as table name would lead to an error. To avoid such error, you need to use enclosed backticks symbol around the table name ‘group’.
Let us now see an example and create a table −
mysql> create table `group` -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (1.26 sec)
Insert some records in the table using insert command −
mysql> insert into `group`(Name) values('Chris'); Query OK, 1 row affected (0.47 sec) mysql> insert into `group`(Name) values('David'); Query OK, 1 row affected (0.36 sec) mysql> insert into `group`(Name) values('Mike'); Query OK, 1 row affected (0.26 sec) mysql> insert into `group`(Name) values('Sam'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select * from `group`;
This will produce the following output −
+----+-------+ | Id | Name | +----+-------+ | 1 | Chris | | 2 | David | | 3 | Mike | | 4 | Sam | +----+-------+ 4 rows in set (0.00 sec)
Advertisements