SQL语句中的 where 1=1啥意思

xiaoxiao2022-06-23  36

在组合查询条件时候多用: String sql="select * from user where 1=1 "; if(username!=null) sql=sql+ " and username='"+username+"'"; if(password!=null) sql=sql+ " and password='"+password+"'"; 这样方便很多,及时username,password两者都为空都可以查询

转载请注明原文地址: https://www.6miu.com/read-4952951.html

最新回复(0)