如何在Sybase中转义单引号

时间:2022-09-15 15:31:10

I come from MySQL and the below query doesn't work in Sybase. How should I escape single quotes?

我来自MySQL,下面的查询在Sybase中不工作。如何避免单引号?

UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12

1 个解决方案

#1


21  

If working with Sybase, having got used to MySQL which more database users have experience you may soon discover you are unable to escape single quotes with backslash in.

如果使用Sybase,已经习惯了MySQL,而数据库用户有更多的经验,那么您可能很快就会发现,您无法通过反斜杠来摆脱单引号。

So how do you escape quotes in Sybase? In fact, in Sybase SQL the single quote acts as the escape character.

那么如何在Sybase中转义引号呢?实际上,在Sybase SQL中,单引号充当转义字符。

See below for an example UPDATE statement in both “languages”:

请参阅下面两种“语言”的更新语句示例:

MySQL

MySQL

UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12

Sybase

赛贝斯公司

UPDATE Animals SET NAME = 'Dog''s friends' WHERE uid = 12

I’m not entirely sure this makes sense to me (especially as it looks like a double quote) but there you go!

我不太确定这对我来说是否有意义(尤其是它看起来像一个双引号),但是你看!

#1


21  

If working with Sybase, having got used to MySQL which more database users have experience you may soon discover you are unable to escape single quotes with backslash in.

如果使用Sybase,已经习惯了MySQL,而数据库用户有更多的经验,那么您可能很快就会发现,您无法通过反斜杠来摆脱单引号。

So how do you escape quotes in Sybase? In fact, in Sybase SQL the single quote acts as the escape character.

那么如何在Sybase中转义引号呢?实际上,在Sybase SQL中,单引号充当转义字符。

See below for an example UPDATE statement in both “languages”:

请参阅下面两种“语言”的更新语句示例:

MySQL

MySQL

UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12

Sybase

赛贝斯公司

UPDATE Animals SET NAME = 'Dog''s friends' WHERE uid = 12

I’m not entirely sure this makes sense to me (especially as it looks like a double quote) but there you go!

我不太确定这对我来说是否有意义(尤其是它看起来像一个双引号),但是你看!