在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. net生成图片验证码--转自Lisliefor

    目前,机器识别验证码已经相当强大了,比较常见的避免被机器识别的方法,就是将验证码的字符串连到一起,这样就加大的识别的难度,毕竟机器没有人工智能.我找了很多的.net生成图片验证码的例子,后来经过一些修 ...

  2. C# RS232串口使用

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  3. sql表与表之间的数据操作

    --把一张表的内容更新到另一张表 update 表1 set 表1.Store=t2.Name from 表2 t2 where 表1.id=t2.id --备份一张表 create table ta ...

  4. R语言和RStudio的一些用法,常用命令等

    控制台: Up/down 回忆之前的命令 Ctrl+Up 回顾命令列表(可先输入前缀进行查找) 焦点: ctrl+ 移动焦点到source编辑器 ctrl+ 移动焦点到console ctrl+L 清 ...

  5. C博客第03次作业---函数

    1.本章学习总结 1.1 思维导图 1.2 本章学习体会及代码量学习体会 1.2.1 学习体会 首先,对于学习了函数的我来说是很开心的,因为学了函数之后可以解决很多以前不懂的问题,可以说函数是C语言中 ...

  6. [USACO5.1] 乐曲主题Musical Themes

    题目链接:戳我 Emmm......hash怎么做啊不会啊 这里是SA后缀数组版本的 就是先两两做差分,作为要处理后缀的数组.普通地求出来h数组之后,我们二分这个答案,然后判定是否合法就行了.是否合法 ...

  7. Neutron 架构图

    与 OpenStack 其他服务一样,Neutron 采用的是分布式架构,包括 Neutorn Server.各种 plugin/agent.database 和 message queue. Neu ...

  8. BZOJ 1001--[BeiJing2006]狼抓兔子(最短路&对偶图)

    1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 29035  Solved: 7604 Descript ...

  9. Dockerfile数据管理

    本文介绍Docker内部以及容器间的数据管理,在容器中管理数据主要有两种方式: 数据卷(Volumes) 挂载主机目录(Bind mounts) 数据卷 数据卷是一个可供一个或则多个目录使用的特殊目录 ...

  10. mysql 数据库自动备份

    @echo offset "Ymd=%date:~,4%%date:~5,2%%date:~8,2%""E:/MySQL/MySQL Server 5.7/bin/mys ...