如何在 MySQL 中將單引號文字作為列值顯示?


要顯示單引號文字,請使用雙引號,例如要編寫您已經,然後在插入時編寫您已經,即用雙引號引起來。我們首先建立一個表 −

mysql> create table DemoTable
(
   Note text
);
Query OK, 0 rows affected (0.57 sec)

使用插入命令在表中插入一些記錄 −

mysql> insert into DemoTable values('You''ve seen the Taj? When?');
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable values('You''ve visited the US?');
Query OK, 1 row affected (0.16 sec)

使用 select 語句從表中顯示所有記錄 −

mysql> select *from DemoTable;

這將生成以下輸出。在這裡,文字您已經正確地顯示 −

+---------------------------------+
| Note                            |
+---------------------------------+
| You've seen the Taj? When?      |
| You've visited the US?          |
+---------------------------------+
2 rows in set (0.00 sec)

更新於:2019 年 10 月 3 日

218 次瀏覽

啟動你的 職業

完成課程以獲得認證

開始
廣告
© . All rights reserved.