在MySQL中,写SQL语句的时候 ,可能会遇到You can't specify target table '表名' for update in FROM clause这样的错误,它的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值。

问题解决

将SELECT出的结果再通过中间表SELECT一遍,这样就规避了错误。

UPDATE t_e_mail_simplify
SET is_seen = '0'
WHERE
mail = 'jenny@echemi.com'
AND uid IN (
SELECT
a.uid
FROM
(
SELECT
uid
FROM
t_e_mail_simplify
WHERE
mail = 'jenny@echemi.com'
AND folder = 'INBOX'
AND is_seen = 1
) a
)

MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法的更多相关文章

  1. [转]MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法

    原文链接:https://blog.csdn.net/qq_29672495/article/details/72668008

  2. Mysql - You can't specify target table '表名' for update in FROM clause 错误解决办法

    背景 在MySQL中,写SQL语句的时候 ,可能会遇到 You can't specify target table '表名' for update in FROM clause 这样的错误 错误含义 ...

  3. MySQL中You can't specify target table '表名'('sn_app_label') for update in FROM clause错误解决办法

    在有些时候有级联关系的数据放在了同一张表中,在写sql语句的时候可能会遇到这样的场景:我要插入两条数据,第一条是父节点,第二条是子节点,关联关系是父节点的自增长id:在写这样的sql语句时有可能就会出 ...

  4. 【mysql 】sql删除重复记录 You can't specify target table '表名' for update in FROM clause

    用下面的语句就报语法出错: delete from tab_record where recordid not in (select  min(c.recordid) as recordid from ...

  5. MySQL中You can't specify target table for update in FROM clause一场

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

  6. 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这个表( ...

  7. MySQL中You can't specify target table for update in FROM clause异常

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

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

    将select出的结果再通过中间表select一遍,这样就规避了错误.注意,这个问题只出现于mysql,mssql和oracle不会出现此问题. mysql中You can't specify tar ...

  9. MySQL--mysql中You can’t specify target table for update in FROM clause错误解决方法

    参考:http://www.jb51.net/article/60926.htm mysql中You can't specify target table for update in FROM cla ...

随机推荐

  1. leetcode 杨辉三角

    给定一个非负整数 numRows,生成杨辉三角的前 numRows 行. 在杨辉三角中,每个数是它左上方和右上方的数的和. 示例: 输入: 5 输出: [ [1], [1,1], [1,2,1], [ ...

  2. Effective Java(1)-创建和销毁对象

    Effective Java(1)-创建和销毁对象

  3. vs 生成事件 +版本号+sed.exe

    set ASMINFO=Properties\AssemblyInfo.csFINDSTR /C:"[assembly: AssemblyVersion(" %ASMINFO% | ...

  4. 批处理系列(18) - 基于BitLocker的开锁上锁

    首先要配置好BitLocker. 上锁 lock.bat @echo off rem 上锁前要结束一些程序,浏览器要注意:有恢复上次关闭项功能,按需设置取消该操作 taskkill /f /t /im ...

  5. Regularjs是什么

    本文由作者郑海波授权网易云社区发布. 此文摘自regularjs的指南, 目前指南正在全面更新, 把老文档的[接口/语法部分]统一放到了独立的 Reference页面. Regularjs是基于动态模 ...

  6. SqlAlchemy操作(三)

    1.基于SQLALCHEMY建表 from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Colu ...

  7. map函数和reduce函数、filter函数的区别

    ①从参数方面来讲:map()函数: map()包含两个参数,第一个是参数是一个函数,第二个是序列(列表或元组).其中,函数(即map的第一个参数位置的函数)可以接收一个或多个参数.reduce()函数 ...

  8. socket agent统一模板

    # -*- coding: utf- -*- # data:-- : # user:DIY # file:agent_eay.py import socket def work(i): sock = ...

  9. 如何解决jade标签没有闭合,如input

    最近用jade模板引擎编写html时发现input编译输出为<input>,而我想要的效果为<input/>, 如何解决呢,这时我们可以这样写: input/     ---& ...

  10. js02--对象、函数、switch、for、异常、表单验证

    现在我们接着来继续学习有关js的一些基础. 1.undefined与null    undefined:当变量声明但尚未赋值时,它的类型就是undefined    null:表示一个不存在的对象,它 ...