“ LIKE”和“ LIKE”之间有什么区别和“ =”在SQL中? [英] What's the difference between "LIKE" and "=" in SQL?
本文介绍了“ LIKE”和“ LIKE”之间有什么区别和“ =”在SQL中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
之间是否有任何区别:
SELECT * FROM users WHERE username="davyjones"
和
SELECT * FROM users WHERE username LIKE "davyjones"
为此,
我主要是桌面应用程序开发人员)
(I think I've bungled up the syntax... pardon me for that,
I'm mostly a desktop app development guy)
推荐答案
按照SQL标准,区别在于对CHAR列中尾随空格的处理。示例:
As per SQL standard, the difference is treatment of trailing whitespace in CHAR columns. Example:
create table t1 ( c10 char(10) );
insert into t1 values ('davyjones');
select * from t1 where c10 = 'davyjones';
-- yields 1 row
select * from t1 where c10 like 'davyjones';
-- yields 0 rows
当然,假设您在符合标准的环境下运行DBMS。顺便说一句,这是CHAR和VARCHAR之间的主要区别之一。
Of course, assuming you run this on a standard-compliant DBMS. BTW, this is one the main differences between CHARs and VARCHARs.
这篇关于“ LIKE”和“ LIKE”之间有什么区别和“ =”在SQL中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文