- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Using MySQL keywords in a query surrounded with single quotes?
If there are multiple MySQL keywords in a query, use backticks symbol rather than single quotes. Let us first create a table. Here, we have used two reserved keywords i.e. ‘key’ and ‘Limit’ −
mysql> create table DemoTable ( `key` int NOT NULL AUTO_INCREMENT PRIMARY KEY , `Limit` int ); Query OK, 0 rows affected (0.72 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(`key`,`Limit`) values(null,80); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable(`key`,`Limit`) values(null,90); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(`key`,`Limit`) values(null,100); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output &mius;
+-----+-------+ | key | Limit | +-----+-------+ | 1 | 80 | | 2 | 90 | | 3 | 100 | +-----+-------+ 3 rows in set (0.00 sec)
Now, we will select the values of one of the columns, which is declared with the reserved keyword ‘key’. Since, we need to fetch the same records, use the backticks symbol −
mysql> select `key` from DemoTable;
This will produce the following output −
+-----+ | key | +-----+ | 1 | | 2 | | 3 | +-----+ 3 rows in set (0.00 sec)
- MySQL throws an error when the table name “match” is not surrounded by single quotes?
- How to escape single quotes in MySQL?
- How to insert date in single quotes with MySQL date formats?
- Using single quotes around database and table name isn’t working in MySQL?
- Set different IDs for records with conditions using a single MySQL query
- Why does the update command in MySQL insist on using slanted single quotes?
- Update two columns with a single MySQL query
- Fetch a specific record using a single MySQL query with AND & OR operator
- MySQL SELECT from two tables with a single query
- Count and sort rows with a single MySQL query
- Which MySQL function can be used to append values of a column with single quotes?
- Single quotes vs. double quotes in C or C++
- Delete records from a MySQL table with IN() in a single query
- MySQL select and insert in two tables with a single query
- Insert multiple values in a temporary table with a single MySQL query?