How to escape single quotes in Sybase

2019-04-04 05:14发布

问题:

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

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

回答1:

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.

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

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

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!



标签: sql sybase