mysql update语句
UPDATE ClientBankInfo
SET
status = 3
WHERE
sn IN (SELECT
sn
FROM
zjzc.ClientBankInfo
WHERE
cardNo IN (SELECT
cardNo
FROM
ClientWenJinCardInfo
WHERE
status = 3)); UPDATE ClientBankInfo p, (SELECT
sn
FROM
zjzc.ClientBankInfo
WHERE
cardNo IN (SELECT
cardNo
FROM
ClientWenJinCardInfo
WHERE
status = 3)) pp
SET p.status = 3
where p.sn=pp.sn 关联更新测试;
mysql> select * from t1;
+------+------+
| id | name |
+------+------+
| 1 | a1 |
| 2 | a2 |
| 3 | a3 |
| 4 | a4 |
| 5 | a5 |
| 6 | a6 |
+------+------+
6 rows in set (0.00 sec) mysql> select * from t2;
+------+------+
| id | name |
+------+------+
| 6 | a6 |
| 5 | a5 |
+------+------+
2 rows in set (0.00 sec) mysql> start transaction;
Query OK, 0 rows affected (0.00 sec) mysql> update t1,t2 set t1.name='xx' where t1.id=t2.id;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0 mysql> select * from t1;
+------+------+
| id | name |
+------+------+
| 1 | a1 |
| 2 | a2 |
| 3 | a3 |
| 4 | a4 |
| 5 | xx |
| 6 | xx |
+------+------+
6 rows in set (0.00 sec) mysql> select * from t2;
+------+------+
| id | name |
+------+------+
| 6 | a6 |
| 5 | a5 |
+------+------+
2 rows in set (0.00 sec) 如果: mysql> update t1,t2 set name='xx' where t1.id=t2.id;
ERROR 1052 (23000): Column 'name' in field list is ambiguous 提示name列是模糊的 /**************
mysql> select * from t2;
+------+------+
| id | name |
+------+------+
| 6 | a6 |
| 5 | a5 |
+------+------+
2 rows in set (0.00 sec) mysql> update t1,t2 set name='xx' where t1.id=t2.id;
ERROR 1052 (23000): Column 'name' in field list is ambiguous
mysql> update t1,t2 set t2.name='xx' where t1.id=t2.id;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0 mysql> select * from t2;
+------+------+
| id | name |
+------+------+
| 6 | xx |
| 5 | xx |
mysql update语句的更多相关文章
- MySQL update语句和insert插入语句写法完全不一样啊,不要搞混
1.mysql update 语句: update user set name = 'xiaoming',age = 18 where uid = 3000; 更新记录时update操作也不需要写ta ...
- Mysql update语句赋值嵌套与在表列中数据后面增加数据
1.Mysql update语句赋值嵌套select 点击(此处)折叠或打开 update a set col=(select col from a where id='5') where id&g ...
- mysql Update语句 语法
mysql Update语句 语法 作用:用于修改表中的数据.广州大理石机械构件 语法:UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 mysql Update语句 示例 ...
- MySQL update 语句与标准SQL不同的地方
[SQL标准中有一个叫同时执行的概念] 同时执行指的是在同一个子句中的各个部分的执行时机是不区分先后的,如下面的SQL语句 ),); +---------+--------+ ) ) | +----- ...
- mysql update语句与limit的结合使用
有时候有需要批量更新数据表中从多少行到多少行的某个字段的值 mysql的update语句只支持更新前多少行,不支持从某行到另一行,比如 UPDATE tb_name SET column_name=' ...
- mysql update语句,修改字段,,或者是批量修改字段
更新一个字段,在它的后面加一个字符串,不查询数据库得到这个字段值 怎么添加?? 例如: 我的test表,有个user字段,我现在想在它后面加了另一个用户的名字 我在mysql数据库这样写 UPDATE ...
- mysql update语句的执行流程是怎样的
update更新语句流程是怎么样的 update更新语句基本流程也会查询select流程一样,都会走一遍. update涉及更新数据,会对行加dml写锁,这个DML读锁是互斥的.其他dml写锁需要等待 ...
- MySQL Update语句用法
用一个表的某列值更新另外一个表的某列值的sql语句: update tableA a innner join tableB b on a.column_1 = b.column_1 set a.col ...
- mysql update语句添加表关联查询
UPDATE tab_game_version as a INNER JOIN tab_game_version as b ON a.id=b.idSET a.advert_data=0 where ...
随机推荐
- Eclipse代码提示功能设置(Java & Eclipse+CDT C/C++)
http://developer.51cto.com/art/200907/136242.htm http://blog.chinaunix.net/u/21684/showart_462486.ht ...
- asp.net mvc4中自定义404
原文地址:http://www.chuchur.com/asp-net-mvc4-404/ 定义404 方法当然有很多种.不同的方法所展现的形式也不一样,用户所体验也不一样.以下提供2两种 方法一: ...
- UIScrollView入门与框架设计
一.概述 1.UIScrollView的contentSize, contentOffSet, contentInsets的作用和使用. 2.UIScrollView的一整个滚动过程的生命周期(开始滚 ...
- HDOJ-1019 Least Common Multiple
http://acm.hdu.edu.cn/showproblem.php?pid=1019 题意:给出n个数,求它们的最小公倍数 对于n个数,它们的最小公倍数等于[前n-1个数的最小公倍数和第n个数 ...
- 【HDU1231】How Many Tables(并查集基础题)
什么也不用说,并查集裸题,直接盲敲即可. #include <iostream> #include <cstring> #include <cstdlib> #in ...
- Makefile中使用foreach生成一类规则
CSDN上,有朋友发帖问了这样一个问题(我按自己的理解翻译一下): 当前目录下有四个静态库文件: liba.a libb.a libc.a libd.a.现在想将它们做成一个动态库libp.so. ...
- 【转】基于Qt, TUIO和TSLIB的嵌入式Linux下的多点触摸设计
这个教程描述了在嵌入式linux下使用Qt如何设置一个支持多点触摸和单点触摸的输入系统.这里假定你已经有了对应的驱动程序,驱动可以从触摸屏的厂商那里获得或者使用一个linux 内核源码中已经存在的驱动 ...
- 判断一个int 型整数 是否为回文数
leetcode 上的题目 Determine whether an integer is a palindrome. Do this without extra space. 由于不能使用额外空间, ...
- HDU 4287 (13.08.17)
Problem Description We all use cell phone today. And we must be familiar with the intelligent Englis ...
- sqlserver中几种典型的等待
为了准备今年的双11很久没有更新blog,在最近的几次sqlserver问题的排查中,总结了sqlserver几种典型的等待类型,类似于oracle中的等待事件,如果看到这样的等待类型时候能够迅速定位 ...