Syntax error MySQL isn’t displaying right single quotation mark(’) after insertion of records

MySQL isn’t displaying right single quotation mark(’) after insertion of records



To display right single quotation marks, you need to alter the table with COLLATE='utf8_unicode_ci'.

Let us first create a table −

mysql> create table DemoTable2000
(
   Name varchar(20)
);
Query OK, 0 rows affected (0.81 sec)

Here is the query to use collate −

mysql> ALTER TABLE DemoTable2000 COLLATE='utf8_unicode_ci';
Query OK, 0 rows affected (0.90 sec)
Records: 0  Duplicates: 0  Warnings: 0

Insert some records in the table using insert command −

mysql> insert into DemoTable2000 values('Chris’s Brown');
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable2000 values('David’s Miller');
Query OK, 1 row affected (0.67 sec)
mysql> insert into DemoTable2000 values('Robert’s Downey');
Query OK, 1 row affected (0.15 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable2000;

This will produce the following output −

+-------------------+
| Name              |
+-------------------+
| Chris’s Brown     |
| David’s Miller    |
| Robert’s Downey   |
+-------------------+
3 rows in set (0.00 sec)
Updated on: 2020-01-02T05:37:56+05:30

372 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements