如果在SQL Quries中给出,为什么不接受单引号(')标记 [英] Why the single quotation (') mark is not accepted if given in SQL Quries
本文介绍了如果在SQL Quries中给出,为什么不接受单引号(')标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想更多地了解为什么单引号(')应该用两个'而不是一个'代替来处理。我们将使用2个单引号替换单引号时可以使用。如果所有其他特殊字符都正常工作,为什么只有单引号会在未正确处理时抛出异常。
提前致谢!!
Hari
Hi All,
I would like to understand more on why the single quotation (') should be handled by replacing with two ' instead of one '. The work around will be working where we replace the single quotation with 2 single quotes.If all other special characters are working fine why only single quote will throw exceptions if not handled properly.
Thanks in Advance !!
Hari
推荐答案
在SQL单引号(')用于识别字符串文字...所以和任何其他语言一样,如果你想在字符串文字中使用它,你必须转义单引号...在类C语言中,通过斜杠(\)完成转义,如\'
,在SQL中,它由一个额外的单引号完成,如''
...
In SQL single quote (') used to identify string literals...So as in any other language, you have to escape single quote if you want to use it inside the string literal...In C-like languages the escaping done by slash (\) like\'
, in SQL it is done by an additional single quote, like''
...
编程语言有一些预定义的规则,规范和保留关键字/单词/字符。单引号(')是SQL查询语法的一部分。它在SQL中启动并终止字符串。
查看处理单引号 [ ^ ]
希望这会对你有所帮助。
干杯
Hi,
Programming languages have some predefined rules, specifications and reserve keywords/words/characters. Single quotes (') is a part of SQL query syntax. It starts and terminates the strings in SQL.
Check Dealing with Single Quote[^]
Hope this will help you.
Cheers
单引号代表varchar值的开头在sql中,您只能传递'在varchar数据类型内。这就是为什么当你要存储像'Pankaj的个人资料'这样的varchar值时你必须像'Pankaj'的个人资料一样传递它
Single quote represent the start of the varchar values in sql and you can only pass ' within varchar datatype only. thats why when you are going to store varchar value like 'Pankaj's Profile' you have to pass it like 'Pankaj''s Profile'
这篇关于如果在SQL Quries中给出,为什么不接受单引号(')标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文