zoukankan      html  css  js  c++  java
  • mysql update不能直接使用select的结果

    在sql server中,我们可是使用以下update语句对表进行更新:
    update a set a.xx= (select yy from b) ;
    但是在mysql中,不能直接使用set select的结果,必须使用inner join:
    update a inner join (select yy from b) c set a.xx = c.yy

     
    例:
    update mb_tariff a inner join   
    mb_tariff_temp b  set a.payment =  b.payment 
    where a.mybus_id = b.mybus_id 
    and a.tariff_id = b.tariff_id 
     
     
     
    自行示例:
    UPDATE USER INNER JOIN (SELECT id,account FROM USER) c SET user.phone=c.account WHERE user.id = c.id

     

  • 相关阅读:
    内置函数二
    内置函数一
    lambda表达式
    函数参数
    set集合
    元组和字典的功能
    列表功能介绍
    分篮子
    松鼠配对?
    奇数次的数?
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/10019978.html
Copyright © 2011-2022 走看看