gpt4 book ai didi

sql - ' ' = ' ' 是什么意思

转载 作者:行者123 更新时间:2023-12-04 23:45:48 25 4
gpt4 key购买 nike

select * from Employees where Name = 'John' or ''=''

此语句检索表中的所有员工。

我不明白 ''='' 是如何解释的?你能解释一下吗?

最佳答案

''='' 总是 true 因为它比较两个空字符串

所以基本上 ''='' 是一个 Tautology 并且您使用的是 OR 条件,因此您的整个条件始终是 。你的 WHERE 也可以写成

where Name = 'John' or 1 = 1

您的查询可以只是 select * from Employees 因为 WHERE 条件无效。

关于sql - ' ' = ' ' 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43048207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com