SQL语句1 = 1 [英] SQL Statement 1=1

查看:142
本文介绍了SQL语句1 = 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


谁能告诉我该条件的用途是什么
1 = 1在WHERE子句中?
在此先感谢

Hi,
Can anyone tell me what is the use of the condition
1=1 in WHERE Clause?
Thanks in advance

推荐答案

可以只是实词句的占位符,例如"if(true){/* ... */}"
Could be just a placeholder for real clause, like "if (true) {/* ... */}"


auauahua可能无需测试就使用参数,是否追加了"WHERE"子句,我在很多系统中都看到了该子句,其中开发人员仅将其用于追加"AND"子句.
SELECT NAME WHERE 1 = 1
AND FILTER1 ="BLA BLA BLA"
AND FILTER2 ="AGA AGA AG"
...

X |
auauahua maybe use the parameters without test if append "WHERE" clause or not, i saw in a lot of systems this clause where developers use only for append the clause "AND"

SELECT NAME WHERE 1=1
AND FILTER1="BLA BLA BLA"
AND FILTER2 ="AGA AGA AG"
...

X|


应该提高其他人没有任何条件的SQL查询的性能.它还允许您构建动态查询,因为在查询末尾使用WHERE 1=1,您需要添加的只是用于您实际情况的AND子句.

It''s supposed to increase performance on a SQL query that otherwsie doesn''t have any conditions. It also allows you to build dynamic queries because with the WHERE 1=1 at the end of your query, all you have to add is AND clauses for your actual conditions.


这篇关于SQL语句1 = 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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