在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
 
 
 

mysql update不能直接使用select的结果的更多相关文章

  1. mysql: update字段中带select

    update字段中带select UPDATE tb_report_type A INNER JOIN (SELECT LEVEL_CODE FROM tb_report_type WHERE id ...

  2. Mysql update语句赋值嵌套与在表列中数据后面增加数据

    1.Mysql update语句赋值嵌套select  点击(此处)折叠或打开 update a set col=(select col from a where id='5') where id&g ...

  3. mysql update select 用法

    之前用SqlServer , update语句对表进行更新:update a set a.xx= (select yy from b) ; 是可以的但是在mysql中,不能直接使用set select ...

  4. MySql Update Select 嵌套

    UPDATE `TB_CM_Dic` SET `ParentID` = (SELECT `ID` FROM (SELECT * FROM `TB_CM_Dic`) AS B WHERE `DicNam ...

  5. MySQL update select组合

    update t_news inner join (select readCount from t_news t2 where t2.id=1) t1 set t_news.readCount = t ...

  6. mysql update操作

    update语法 Single-table语法: UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=ex ...

  7. mysql update语句

    UPDATE ClientBankInfo SET status = 3 WHERE sn IN (SELECT sn FROM zjzc.ClientBankInfo WHERE cardNo IN ...

  8. Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause

    Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FRO ...

  9. mysql update 忘加 where 文件恢复

    前提条件:mysql :data_row_format=rowmysql> show variables like '%image%';+------------------+-------+| ...

随机推荐

  1. HighCharts 后台加载数据的时候去掉默认的 series

    var chart; var options = { chart: { renderTo: 'container', type:'line' }, title: { text: '历史趋势时序图', ...

  2. BFS+状态压缩 hdu-1885-Key Task

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1885 题目意思: 给一个矩阵,给一个起点多个终点,有些点有墙不能通过,有些点的位置有门,需要拿到相应 ...

  3. 380. Insert Delete GetRandom O(1)

    经过昨天的消沉 今天我振作了 设计个数据结构,添加,删除,随机获取都是O(1). 怎么会有这么牛逼的数据结构,所以肯定相应的要耗费空间. 添加和获取耗时O(1)是Array的特性,或者说是Map/Ta ...

  4. easyui常用控件样式收藏

    CSS类定义: div easyui-window                               window窗口样式 属性如下: 1)       modal:是否生成模态窗口.tru ...

  5. [React] React Fundamentals: Precompile JSX

    The JSX Transformer library is not recommended for production use. Instead, you'll probably want to ...

  6. Hadoop-2.2.0中文文档—— Common - 服务层认证

    目的 此文档描写叙述了怎样为Hadoop配置和管理 Service Level Authorization . 预备条件 确保已经安装Hadoop,配置和设置都正确了. 很多其它细节,请看:* 首次使 ...

  7. UVA - 10239 The Book-shelver's Problem

    Description Problem D The Book-shelver's Problem Input: standard input Output: standard output Time ...

  8. 启动MYSQL密码审计插件

    http://www.innomysql.com/article/25717.html [root@server-mysql plugin]# pwd /usr/local/mysql56/lib/p ...

  9. ASP.NET Web API(二):安全验证之使用HTTP基本认证

    在前一篇文章ASP.NET Web API(一):使用初探,GET和POST数据中,我们初步接触了微软的REST API: Web API. 我们在接触了Web API的后就立马发现了有安全验证的需求 ...

  10. JSP/Servlet 中的事件处理

    写过AWT或Swing程序的人一定对桌面程序的事件处理机制印象深刻:通过实现Listener接口的类可以在特定事件(Event)发生时,呼叫特定的方法来对事件进行响应. 其实我们在编写JSP/Serv ...