Home> Database> SQL> body text

What does where 1=1 mean in SQL statement?

angryTom
Release: 2020-02-13 17:19:58
Original
7716 people have browsed it

What does where 1=1 mean in SQL statement?

What does where 1=1 mean in the sql statement?

where 1=1 should be automatically generated by a program (such as Java). The conditions after 1=1 in the where condition are dynamically changed through the if block. For example:

String sql="select * from table_name where 1=1"; if( conditon 1) { sql=sql+" and var2=value2"; } if(conditon 2) { sql=sql+" and var3=value3"; }
Copy after login

where 1=1 is to avoid grammatical errors caused by the first word after the where keyword being directly "and".

PHP Chinese website has a large number of freeSQL tutorials, everyone is welcome to learn!

The above is the detailed content of What does where 1=1 mean in SQL statement?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!