update products set products_price="SELECT products_price  from products where metatags_title_tagline_status=0"+30  类似于这样的sql语句
  
我的意思就是products表里面有个字段products_price把他的值都加30  主要是这个字段没规律的 

解决方案 »

  1.   

    update products 
    set products_price=(SELECT products_price from products where metatags_title_tagline_status=0)+30 
    这样 用括号把查询括起来~
      

  2.   

    不行啊我之前用过报错    #1093 - You can't specify target table 'products' for update in FROM clause 
      

  3.   

    就是不知道mysql支不支持这样的
      

  4.   

    update products set products_price=(SELECT products_price  from products where metatags_title_tagline_status=0)+30支持这样的,用(),另外要确保SELECT products_price  from products where metatags_title_tagline_status=0仅返回一条记录否则就加上MINupdate products set products_price=(SELECT min(products_price)  from products where metatags_title_tagline_status=0)+30
      

  5.   

    还是报错#1093 - You can't specify target table 'products' for update in FROM clause SELECT min(products_price) from products where metatags_title_tagline_status=0  我加这个条件就是把表里面所有的字段都满足 或者不要where metatags_title_tagline_status=0也行的支持这样的,用(),另外要确保SELECT products_price from products where metatags_title_tagline_status=0仅返回一条记录否则就加上MIN  确实是返回多条的记录的
      

  6.   

    =(SELECT products_price from products where metatags_title_tagline_status=0)
    返回多条记录?
    那不可以那么写。。你加个限制 
    SELECT min(products_price) from products where metatags_title_tagline_status=0
    SELECT max(products_price) from products where metatags_title_tagline_status=0