- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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) while 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)
- Fix Error in MySQL syntax while creating a table column with name “index”?
- Select the table name as a column in a UNION select query with MySQL?
- While creating a MySQL table use the reserved keyword ‘Key’
- Can we use reserved word ‘index’ as MySQL column name?
- How to resolve the error that occurs while using a reserved word as a table or column name in MySQL?
- I used ‘from’ and ‘to’ with backticks as column titles in my database table. Now, how do I SELECT them?
- What is the MySQL syntax error in this query – Creating a table with reserved keyword?
- Declare syntax error in MySQL Workbench?
- Error occurs when table name “references” is set while creating a table
- MySQL query to search a string ‘demo’ if someone mistakenly types ‘deom’?
- How to use ‘while loop’ in Java?
- In the query [SELECT column1, column2 FROM table_name WHERE condition; ] which clause among ‘SELECT’, ‘WHERE’ and ‘FROM’ is evaluated in the last by the database server and why?
- Display an error while inserting duplicate records in a MySQL table
- Find all the names beginning with the letter 'a' or ‘b’ or ‘c’ using MySQL query?
- Underscore as a table name in MySQL is possible?