How does one escape an apostrophe in db2 sql

孤者浪人 提交于 2019-12-03 09:29:20

Use two apostrophes '' to get a single apostrophe on DB2 too, according to the DB2 Survival Guide. Isn't that working for you?

Brabster is correct. You are supposed to escape ' with ''
So to insert O'Hara , you will have to write O''Hara
Excerpt from: http://www.michael-thomas.com/tech/db2/db2_survival_guide.htm

Escape character.

To insert a single quote, use 2 single quotes ( '' ). To insert pet's use the following pet''s.
Example: insert into MYTABLE (question,answer) values ('What is your pet''s name?','blacky') `

just make it simple.

Keep your query in the single quotes ('). and where ever you are using qoutes, make it double. for e.g. u want to insert ...... I'm fine. There's an answer.

in SQL we need to give ....... 'I''m fine. There''s an answer.'

I was trying to insert into DB2 a regex expression for an email address. I thought I had to escape all characters as outlined at the proceeding link, but escaping only the single quote contained within the regex seems to be all I needed to escape to get it properly inserted into the database:

https://www.ibm.com/support/knowledgecenter/en/SSEPGG_10.1.0/com.ibm.db2.luw.admin.ts.doc/doc/c0059609.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!