You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据。

出现以上错误,是因为想将表自身的字段A的值作为被更新字段B的值而导致的。

"自身更新自身"的正确写法:

  1. UPDATE t_loan SET f_biddingAmount =
  2. (
  3. SELECT amount FROM(
  4. SELECT ln.*, ln.f_amount amount FROM t_loan ln
  5. ) lnnew WHERE lnnew.f_loanId = t_loan.f_loanId
  6. );

含义,查询t_loan中f_amount值作为f_biddingAmount被更新的值。

我们想达到的效果是将t_loan表中的f_amount值作为表自身f_biddingAmout被更新的值,

也就是将t_loan表中的f_biddingAmount都更新成f_amount的值。

我们也可以在每一个select,update后面跟上条件等执行SQL。

比如,在SELECT ln.*, ln.f_amount amount FROM t_loan ln后面加上WHERE条件等。

以上问题只针对mysql数据库使用这么麻烦的写法,oracle中针对这种需求写起来相对比较简单。

原文:http://blog.csdn.net/yhl_jxy/article/details/50856619

MYSQL 1093 之You can't specify target table for update in FROM clause解决办法的更多相关文章

  1. MySQL之You can't specify target table for update in FROM clause解决办法

    这篇文章主要介绍了mysql中You can't specify target table for update in FROM clause错误解决方法,需要的朋友可以参考下 MySQL中You c ...

  2. MYSQL之You can't specify target table for update in FROM clause解决办法

    mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...

  3. mysql You can't specify target table for update in FROM clause解决方法

    mysql You can't specify target table for update in FROM clause解决方法出现这个错误的原因是不能在同一个sql语句中,先select同一个表 ...

  4. mysql错误:1093-You can’t specify target table for update in FROM clause的解决方法

    update语句中包含的子查询的表和update的表为同一张表时,报错:1093-You can’t specify target table for update in FROM clause my ...

  5. mysql修改删除You can't specify target table for update in FROM clause的问题

    表中出现重复数据,需要删除重复数据,只保留一条 DELETE FROM crm_participant WHERE id IN ( SELECT c.id cid FROM crm_participa ...

  6. MYSQL错误:You can't specify target table for update in FROM clause

    这句话意思是:不能先select再更新(修改)同一个表. 可以再外嵌套多一层,这个问题只有mysql有,mssql和oracle都没有. # 出错delete from Person where Id ...

  7. mysql中You can't specify target table for update in FROM clause

    使用mysql在删除表中重复记录 delete from user where username in (select user name form(select username from user ...

  8. MySQL 出现You can't specify target table for update in FROM clause错误解决方法

    MySQL出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...

  9. mysql 出现You can't specify target table for update in FROM clause错误的解决方法

    mysql出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...

随机推荐

  1. redis配置文件redis.conf翻译、解释以及常用注意事项(持续更新中...)

    # Redis configuration file example. #Redis 配置文件的示例 #如何利用配置文件启动Redis # Note that in order to read the ...

  2. windows 2008 启用.NET Framework 3.5

    Win2008下已经集成了.NET 3.5.1 framework,需要在管理界面打开! 方法和步骤是: 服务器管理器 -> 功能 -> 添加功能 然后在“选择功能”界面勾选“.NET F ...

  3. SVN服务器搭建和使用-转载

    SVN服务器搭建和使用(一)-转载 原文地址:http://www.cnblogs.com/xiaobaihome/archive/2012/03/20/2407610.html Subversion ...

  4. js 把数组对象按照某个属性进行排序

    var arr=[{a:1},{a:3},{a:2}]; function objSort(prop){ return function (obj1, obj2) { var val1 = obj1[ ...

  5. P1244 青蛙过河

    P1244 青蛙过河NOI2000主要思想:数学归纳法 递推 压位高精度 化归 理解能力和找规律的能力题意再述:1.青蛙从上到下必须连续递增或者下面是石墩 而不能是1 12 33 4而且每时每刻都要满 ...

  6. 移动端h5需要注意的一些事

    1.移动端点击a标签出现的背景色 a, a:hover, a:active, a:visited, a:link, a:focus { -webkit-tap-highlight-color: rgb ...

  7. UE4新手编程之创建空白关卡和添加碰撞体

    让我们接着上次继续学习UE4引擎,今天我们学习下怎样创建空白的关卡以及添加碰撞物体. 一. 创建空白关卡 1) 点击文件 -> 新建关卡(或者按快捷键Ctrl+N). 2) 你可以选择Defau ...

  8. 51nod 1584加权约数和

    学到了好多东西啊这题... https://blog.csdn.net/sdfzyhx/article/details/72968468 #include<bits/stdc++.h> u ...

  9. DrawFrameControl 绘制标准控件

    BOOL DrawFrameControl( HDC hDC,        // 设备环境句柄    LPRECT lpRect,  // 矩形区域    UINT nType,     // 控件 ...

  10. Codeforces Round #375 (Div. 2) D. Lakes in Berland 贪心

    D. Lakes in Berland 题目连接: http://codeforces.com/contest/723/problem/D Description The map of Berland ...