mysql两表间select/update/delect
来源:互联网 发布:奥普和欧普哪个好 知乎 编辑:程序博客网 时间:2024/06/13 09:34
--创建测试表,插入测试数据create table t1( col1 varchar(10), col2 varchar(10));create table t2( col1 varchar(10), col3 varchar(10));--查询,效率对比未知select t1.*,t2.* from t1,t2 where t1.col1 = t2.col1; --先连接再查询select t1.*,t2.* from t1 join t2 on t1.col1 = t2.col1; --先查询在连接--更新update t1,t2 set t1.col2 = t2.col3 where t1.col1 = t2.col1;update t1 join t2 on t1.col1 = t2.col1 set t1.col2 = t2.col3;--oracle中可行,mysql报错--[Err] 1288 - The target table t of the UPDATE is not updatableupdate (select t1.col2 f2,t2.col3 f3 from t1,t2 where t1.col1=t2.col1) t set t.f2=t.f3;update (select t1.col2 f2,t2.col3 f3 from t1 left join t2 on t1.col1 = t2.col1) t set t.f2=t.f3;--删除delete t1.*,t2.* from t1,t2 where t1.col1 = t2.col1;delete t1.* from t1 join t2 on t1.col1 = t2.col1;
阅读全文
0 0
- mysql两表间select/update/delect
- mysql update by select
- mysql update select 问题
- mysql update select
- mysql update select
- mysql SELECT ... FROM UPDATE
- mysql select for update
- mysql select for update
- mysql update select 语句
- MYSQL SELECT FOR UPDATE
- MySQL update 嵌套 select
- MySQL语法(二 )--update--and 和 or--order by--delect(数据的操作)----drop(库的操作)
- mysql中的select * for update
- Mysql中的select * for update
- mysql中select * for update
- mysql中select * for update
- mysql中select * for update
- mysql中select * for update
- 面向对象设计的SOLID原则
- python3之输入输出格式
- continue语句
- 给深度学习入门者的Python快速教程
- 背包入门--多重背包 hd 2079
- mysql两表间select/update/delect
- 指针
- 2014年good fellow提出GANs论文译本
- 讲解.NET 集合中使用Count属性和扩展方法Count<T>()区别
- java n*n的二维数组转置,不开辟新的空间
- Hadoop DataNode 无法连接到主机NameNode
- maven配置(阿里云)
- sklearn学习——SVM
- Android --- 常用的系统服务(二)