update ad_category set order_total=order_total+1 where category_id = (select a.category_id as i,b.category_id as id,c.category_id as ids,d.category_id as idss from ad_category as a,ad_category as b,ad_category as c,ad_category as d where a.parent_id=b.category_id and b.parent_id=c.category_id and c.parent_id=d.category_id and a.category_id=10);这样会报错Operand should contain 1 column(s) 注:一条sql就能搞定 不要多条sql或存储过程..... 感谢各位大侠 在线等.......

解决方案 »

  1.   

    给出表结构,否则我们都不知道你的表字段对应什么,你的category_id和哪个表的category_id对应了,那么多都是同样的字段名
      

  2.   

    就是一个表 ad_category 这个表是
    | category_id        | int(11)       | NO   | PRI | NULL    | auto_increment |
    | category_name      | varchar(100)  | NO   |     | NULL    |                |
    | parent_id          | int(11)       | NO   |     | NULL    |                |
      

  3.   

    如果不用一条sql的话 我就不会问了 我就想知道有没有以可以一条sql搞定的
      

  4.   

    MySQL貌似没辙MSSQL可以用with 语句
      

  5.   

    其实,你可以考虑用php分两次查询,第一次用php递归查id,第二次再查你要的结果,效率不会差多少的.
      

  6.   

    语句应该类似update ad_category ad inner join(select a.category_id as i,b.category_id as id,c.category_id as ids,d.category_id as idss from ad_category as a,ad_category as b,ad_category as c,ad_category as d where a.parent_id=b.category_id and b.parent_id=c.category_id and c.parent_id=d.category_id and a.category_id=10) ason ad.category_id=as.category_idset ad.order_total=ad.order_total+1 where 1;
      

  7.   

    ....
    as 是保留字,改改update ad_category ad inner join(select a.category_id as i,b.category_id as id,c.category_id as ids,d.category_id as idss from ad_category as a,ad_category as b,ad_category as c,ad_category as d where a.parent_id=b.category_id and b.parent_id=c.category_id and c.parent_id=d.category_id and a.category_id=10) asson ad.category_id=ass.category_idset ad.order_total=ad.order_total+1 where 1;
      

  8.   

    不行的吧 ad.category_id=ass.category_id 这个ass里面都木有字段category_id 
      

  9.   

    额,没仔细看,都同一表在操作,树形sql,mysql板有讨论过,存储过程能弄出来都算不错了