update可不可以出现在select 的where 条件中出发点很简单。发现了网站的一个漏洞。
select *
form ttt
where a='xxxx'
现在可以像xxxx传递sql语句。
我试过直接用 where a='xxxx' and (update ……) 好像语法不对?
不知还有什么方法没?

解决方案 »

  1.   

    update可以批量关联更新,参考:
    http://blog.csdn.net/downmoon/archive/2006/09/28/1301932.aspx
      

  2.   

    update可不可以出现在select 的where 条件中--不可以。
      

  3.   


    update table set col1= ttt.col1 ,col2=ttt.col2 ... from ttt where ttt.a='XXX' ...
      

  4.   

    LZ是想玩sql注入对吧,做坏事?
      

  5.   

    楼主是不要这样:
    UPDATE ttt
    SET ....
    where a='xxxx'
      

  6.   

    select *
    form ttt
    where a='xxxx'select *
    form ttt
    where a='xxx' or 1=1 ; update ttt set a = 0
      

  7.   

    update不能放在where后面当条件使用
      

  8.   

    的确不是。我想在where中加入uppdate 更新数据库。
    前面的select ……我都不能改,只能在一个where的条件中做手脚……
      

  9.   

    SELECT count(*) FROM 
    ( SELECT * from BULLETIN 
    where BULLETIN.ID='b3c8995e'
    order by BULLETIN.RECOMMENDLEVEL desc,BULLETIN.PUBLISHED desc ) temp where ROWNUM <= 10 ) WHERE num > 0]; 
    这是暴出来的sql代码,在ID那里存在注入。
      

  10.   

    --如果是动态的:
    DECLARE @sql VARCHAR(8000)
    set @sql='
    SELECT count(*) FROM 
    ( SELECT * from BULLETIN 
    where BULLETIN.ID=''b3c8995e'') t; update BULLETIN set ID=... WHERE ...'
    --order by BULLETIN.RECOMMENDLEVEL desc,BULLETIN.PUBLISHED desc ) temp where ROWNUM <= 10 ) WHERE num > 0];'
      

  11.   


    报的错误是org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar因此应该没有'……'--……'这样的问题。