Do not use single quotes. You need to use backticks around the table name match, since it is a reserved name in MySQL. Following is the error that occurs :
mysql> select *from match; ERROR 1064 (42000) : 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 'match' at line 1
Let us first create a table and fix the occurrence of the above error using backticks around the reserved word match, used here as table name −
mysql> create table `match` ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, PlayerName varchar(20) ); Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command. Now, wherever the reserved word is used, surround with backticks −
mysql> insert into `match`(PlayerName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into `match`(PlayerName) values('Bob'); Query OK, 1 row affected (0.16 sec) mysql> insert into `match`(PlayerName) values('David'); Query OK, 1 row affected (0.24 sec) mysql> insert into `match`(PlayerName) values('Mike'); Query OK, 1 row affected (0.15 sec) mysql> insert into `match`(PlayerName) values('Sam'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from `match`;
This will produce the following output −
+----+------------+ | Id | PlayerName | +----+------------+ | 1 | Chris | | 2 | Bob | | 3 | David | | 4 | Mike | | 5 | Sam | +----+------------+ 5 rows in set (0.00 sec)