What are the different quote marks of MySQL?

MySQLMySQLi Database

You can use backticks and single quotes in MySQL. The backtick can be used around the column name and table name while single quotes can be used for the column name values.

Let us take an example for both the quote marks. To understand the above syntax, let us create a table. The query to create a table is as follows −

mysql> create table QuotesDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(20),
   -> UserAge int
   -> );
Query OK, 0 rows affected (2.53 sec)

Insert some records in the table using insert command −

mysql> insert into QuotesDemo(`UserName`,`UserAge`) values('John',23);
Query OK, 1 row affected (0.21 sec)
mysql> insert into QuotesDemo(`UserName`,`UserAge`) values('Carol',21);
Query OK, 1 row affected (0.24 sec)
mysql> insert into QuotesDemo(`UserName`,`UserAge`) values('Sam',22);
Query OK, 1 row affected (0.11 sec)

Now you can display all records from the table using a select statement. The query is as follows −

mysql> select *from `QuotesDemo`;

Output

+----+----------+---------+
| Id | UserName | UserAge |
+----+----------+---------+
|  1 | John     |      23 |
|  2 | Carol    |      21 |
|  3 | Sam      |      22 |
+----+----------+---------+
3 rows in set (0.00 sec)

Here is the query showing the usage of both the quotes −

mysql> select *from `QuotesDemo` where `UserName` = 'Carol';

Output

+----+----------+---------+
| Id | UserName | UserAge |
+----+----------+---------+
|  2 | Carol    | 21      |
+----+----------+---------+
1 row in set (0.00 sec)
raja
Published on 19-Mar-2019 11:01:17
Advertisements