MySQL 查询中的单引号 [英] Single Quotes in MySQL queries
本文介绍了MySQL 查询中的单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个 MySQL 查询,例如:
SELECT this FROM that WHERE id='10'
和
SELECT this FROM that WHERE id=10
两者似乎都可以正常工作.
MySQL 查询中的单个语音标记有什么用?什么时候使用它们是正确的?
解决方案
如果值为字符串,则必须使用'
或"
.
如果值是一个数字,就像在你的例子中一样,你不必使用 '
,但是如果你把它放在 '
s 周围,MySQL 会处理它.>
If I have a MySQL query like:
SELECT this FROM that WHERE id='10'
and
SELECT this FROM that WHERE id=10
both seem to work correctly.
What is the use of the single speech marks in MySQL queries? When is it correct to use them?
解决方案
If the value is a string, you have to use '
or "
.
If the value is a number, like in your example, you have not to use '
, but MySQL handles it if you put it around '
s.
这篇关于MySQL 查询中的单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文