MySQL QUOTE() 函数可用于附加带有单引号的列值。为此,我们必须将列名作为 QUOTE() 函数的参数传递。下面用“Student”表的数据来演示
mysql> Select Name, ID, QUOTE(Subject)AS Subject from Student; +---------+------+-------------+ | Name | ID | Subject | +---------+------+-------------+ | Gaurav | 1 | 'Computers' | | Aarav | 2 | 'History' | | Harshit | 15 | 'Commerce' | | Gaurav | 20 | 'Computers' | | Yashraj | 21 | 'Math' | +---------+------+-------------+ 5 rows in set (0.00 sec)
相反,也可以借助 CONCAT() 函数来完成,如下所示 -
mysql> Select Name, ID, CONCAT('''',Subject,'''')AS Subject from Student; +---------+------+-------------+ | Name | ID | Subject | +---------+------+-------------+ | Gaurav | 1 | 'Computers' | | Aarav | 2 | 'History' | | Harshit | 15 | 'Commerce' | | Gaurav | 20 | 'Computers' | | Yashraj | 21 | 'Math' | +---------+------+-------------+ 5 rows in set (0.00 sec)
为此目的,QUOTE() 函数非常易于使用。
以上是哪个 MySQL 函数可用于附加带有单引号的列值?的详细内容。更多信息请关注PHP中文网其他相关文章!