深入理解where 1=1的用处
where 1=1有什么用?在SQL语言中,写这么一句话就跟没写一样。 select * from table1 where 1=1与select * from table1完全没有区别,甚至还有其他许多写法,1<>2,’a’=’a’,’a'<>’b’,其目的就只有一个,where 的条件为永真,得到的结果就是未加约束条件的。 在SQL注入时会用到这个,例如select * from table1 where name=’lala’给强行加上select * from table1 where name=’lala’ or 1=1这就又变成了无约束的查询了。 最近发现的妙用在于,在
下载地址
用户评论