当前位置:网站首页>A solution to the problem that MySQL cannot update the query result set
A solution to the problem that MySQL cannot update the query result set
2022-06-09 14:31:00 【dmhxm】
1、update The table and... Of the subquery contained in the update When the table of is the same table , Report errors
-- Wrong cases
UPDATE tab_user
SET sex = ' Woman '
WHERE
uid IN (
SELECT
uid
FROM
tab_user
WHERE
STATUS = 'N')
-- Report errors :You can't specify target table 'tab_user' for update in FROM clause
-- terms of settlement
-- Nest the subquery result set one level select And take an alias to solve
UPDATE tab_user
SET sex = ' Woman '
WHERE
uid IN (
SELECT
uid
FROM
( SELECT uid FROM tab_user WHERE `status` = 'N' ) AS temp)
2. When you need to modify the result set of a linked table query, you will be prompted that you cannot update Result set
-- Solution
-- Modify table join query table , direct update Modify the table
UPDATE A surface AS i
RIGHT JOIN (
SELECT
b.*
FROM
A surface a
INNER JOIN B surface b ON a.studentcode = b.CODE
WHERE
a.schoolitemcode != b.schoolitemcode
) AS s ON i.studentcode = s.CODE
SET i.schoolitemcode = s.schoolitemcode
边栏推荐
- #yyds干货盘点# 解决剑指offer:矩形覆盖
- ThreadLocal基础及高级使用
- 破解程序员的 5 大迷思,《新程序员 004》正式上市!
- Import word document picture VM virtual machine network settings
- MySQL数据库(25):外键 foreing key
- 多元时间序列分析 —— 因果检验
- Uniswapv2 peripheral contract learning (VIII) -- exampleswaptoprice sol
- Best practices for WSL installation
- C# 计算两个时间间隔
- 输入一行字符(最多80个),从第location个位置开始,截取number个字符并将其输出。
猜你喜欢

CSDN音视频技术开发者在线调研

喜报 | 旺链科技签约汨罗市文旅体产业项目,打造“链”上数字乡村
![[database] final review: SQL statement, definition and judgment of normal form, ER diagram to relational mode](/img/c1/4f7777094c66216c561c71e4706ebb.png)
[database] final review: SQL statement, definition and judgment of normal form, ER diagram to relational mode

How can minority majors solve the problem of "growth"?

ARIMA加法季节模型

线程池创建方式详解

C language structure | linked list

Like the brain, the nano magnet network can be used to perform AI like computing processing, which can reduce energy consumption

小众专业如何解决“成长”的烦恼?

51 MCU timer 0 is used as time reference and delay function reference
随机推荐
华为,这也太强了吧..
联调这夜,我把同事打了...
【深度优先搜索】最大乘积:排列
C语言————贪心法
应用软件效率测试的执行策略
In WinCC, how to use C script to set + reset + negate variables?
机器学习基础备忘录
IDEA复制方法的全路径
栈的基本方法及相关问题
Code implementation WordPress writing articles can adjust font size
ThreadLocal还不会?来看看!
Is it reliable and safe to open an account for external futures?
发邮件:错排问题的分析
使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
Ffmpeg support for HLS slicing
Subvert cognition! Can data enhancement and regularization lead to imperceptible disasters?
Little known beyond relu, it was discovered three years later: the activation functions used by Bert, gpt-2, etc
入职腾讯外包一个月,我离职了
15 Uncaught TypeError: Cannot set properties of null (setting ‘onclick‘)
4427 node sum in tree (greedy)