

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
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)
- Related Questions & Answers
- 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?
- Update two columns with a single MySQL query
- Set different IDs for records with conditions using a single MySQL query
- Single quotes vs. double quotes in C or C++
- Count and sort rows with a single MySQL query
- MySQL SELECT from two tables with a single query
- Why does the update command in MySQL insist on using slanted single quotes?
- Fetch a specific record using a single MySQL query with AND & OR operator
- Single and Double Quotes in Perl
- Delete records from a MySQL table with IN() in a single query
- How to bulk update MySQL data with a single query?
- Which MySQL function can be used to append values of a column with single quotes?
- Using single quotes around database and table name isn’t working in MySQL?
Advertisements