如何在mysql varchar数据类型列中添加“喜欢特殊字符"? [英] how to add ' like special characters in mysql varchar data type column?

查看:534
本文介绍了如何在mysql varchar数据类型列中添加“喜欢特殊字符"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过查询将字符串作为婴儿的世界"插入varchar类型的列中,但显示错误. 我还需要在查询中添加其他内容,以便它接受该符号

I am trying to insert string as "baby's world" into the column of type varchar through query but shows me error. Is there anything else i need to put to the query so that it accept that symbol

推荐答案

在其前面加上反斜杠,如下所示:

put a backslash in front of it like so:

"Baby\'s world"

您可以使用以下命令在字符串中查找并替换它们:

You can find and replace them in your string using the following:

str.Replace('\'', '\\\'')

我不确定这最后一部分,但您需要通过在其前面添加一个\来转义"'和\.因此,这似乎还不错(无法测试,因为我不是C#程序员.

I'm not 100% sure about this last part, but you need to 'escape' the ' and \ by adding a \ in front of it. So it would seem alright (can't test as i'm not a C# programmer.

这篇关于如何在mysql varchar数据类型列中添加“喜欢特殊字符"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆