How to insert records with double quotes in MySQL?


To insert records with double quotes, use the backslash (\) as in the below syntax −

Syntax

insert into yourTableName values('\"yourValue\"');

Let us first create a table −

mysql> create table DemoTable
   -> (
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (0.63 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values('\"John\"');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('\"Chris\"');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('\"Adam Smith\"');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('\"Carol\"');
Query OK, 1 row affected (0.20 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output. The double quotes around the records can be easily seen −

+--------------+
| Name         |
+--------------+
| "John"       |
| "Chris"      |
| "Adam Smith" |
| "Carol"      |
+--------------+
4 rows in set (0.00 sec)

Updated on: 12-Dec-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements