The reason

When you enter a company, you can see that almost every SQL project has a “where 1 = 1” SQL concatenation. Then I asked Google, and some people said there was nothing bad, and some people said there were shortcomings, so try it yourself.

Practice is the sole criterion for testing truth

  • advantages

    SQL concatenation (); SQL concatenation ();

  • disadvantages

    Is there really a downside? Some people on the Internet say that adding 1=1 will not index, then explain

    LOGINID Unique index, SQL executionexplain select * from frame_user where LOGINID = 'admin';The result is an index, which is normal;

    Sqlexplain select * from frame_user where 1=1 and LOGINID = ‘admin’; , the result is exactly the same, also went through the index

The results of

Where 1=1 doesn’t hurt, so use whatever you want

If any of the above is wrong, please point out, anyway, don’t understand just ask!