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 函数可用于附加带有单引号的列值?的详细内容。