MySQL中相当于Python三重引号字符串的是什么?
在Python中,我可以使用三重引号的字符串,这样就可以轻松定义包含 '
、反引号或 "
的字符串,而不需要担心这些符号的问题:
hello = """
This string is bounded by triple double quotes (3 times ").
Unescaped newlines in the string are retained, though
it is still possible to use all normal escape sequences.
Whitespace at the beginning of a line is
significant.
This string ends in a newline.
"""
在PHP中,我可以使用heredoc(也就是 <<<
)来做到这一点:
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
那么在MySQL中,我该怎么做呢?现在我必须确保对我用来分隔的字符进行转义,比如如果我用 '
作为分隔符,我在字符串中就得写成 \'
:
UPDATE article
SET article_text ='
Extra-virgin olive oil is a staple in any chef\'s kitchen.
'
我希望能够像这样做:
UPDATE article
SET article_text ='''
Extra-virgin olive oil is a staple in any chef's kitchen.
'''