gpt4 book ai didi

mysql - 如何在MySql中转义撇号(单引号)?

转载 作者:行者123 更新时间:2023-11-29 16:14:12 25 4
gpt4 key购买 nike

MySQL documentation说它应该是\'。然而,scite 和 mysql 都显示 '' 有效。我看到了,它有效。我该怎么办?

最佳答案

您引用的 MySQL 文档实际上比您提到的要多一些。它还说,

A “'” inside a string quoted with “'” may be written as “''”.

(此外,您链接到 MySQL 5.0 version of Table 8.1. Special Character Escape Sequences ,当前版本是 5.6 — 但当前的 Table 8.1. Special Character Escape Sequences 看起来非常相似。)

我认为Postgres note on the backslash_quote (string) parameter内容丰富:

This controls whether a quote mark can be represented by \' in a string literal. The preferred, SQL-standard way to represent a quote mark is by doubling it ('') but PostgreSQL has historically also accepted \'. However, use of \' creates security risks...

这对我来说,使用双单引号字符是比使用反斜杠转义单引号更好的整体和长期选择。

现在,如果您还想在等式中添加语言选择、​​SQL 数据库选择及其非标准怪癖以及查询框架选择,那么您最终可能会得到不同的选择。您没有提供太多有关您的限制的信息。

关于mysql - 如何在MySql中转义撇号(单引号)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54975177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com