Mysql实例mysql多表join时候update更新数据的方法
发布时间:2020-07-21 10:04:51 所属栏目:MySql 来源:互联网
导读:介绍《Mysql实例mysql多表join时候update更新数据的方法》开发教程,希望对您有用。
《Mysql实例mysql多表join时候update更新数据的方法》要点: 代码如下: update item i,resource_library r,resource_review_link l set i.name=CONCAT('Review:',r.resource_name) where i.item_id=l.instance_id and l.level='item' and r.resource_id=l.resource_id and i.name='' JOIN UPDATE & JOIN DELETE 代码如下: update a set a.schoolname = b.schoolname from tb_Std as a join tb_Sch as b on a.School = b.School where a.std_year = 2005 go /* (2 row(s) affected) */ select * from tb_Std as a join tb_Sch as b on a.School = b.School /* A School A A School 2 2005 A A School A A School 3 2004 C A School C C School 4 2005 D D School D D School (4 row(s) affected) */ 代码如下: delete a from table1 a,table2 b where a.col1 = b.col1 and a.col2 = b.col2 The above SQL statement runs fine in SQL Server. If the Oracle 9i has different syntax or if there is any other way to accomplish this with a single delete statement that would be really helpful. > Hi, > > Is the following delete statement possible in Oracle 9i. > > delete a > from table1 a,table2 b > where a.col1 = b.col1 > and a.col2 = b.col2 > > The above SQL statement runs fine in SQL Server. > > If the Oracle 9i has different syntax or if there is any other way to accomplish this with a single delete statement that would be really helpful. > > Thanx in advance. > > -Bheem Bheem, Try this: DELETE FROM table1 a where exists (select 1 from table2 b where a.col1 = b.col1 and a.col2 = b.col2); Hope this helps, Tom K. (编辑:鄂州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Mysql入门Mysql 5.7.19 winx64 ZIP Archive 安装及使用过程
- 如何在Sails.js中定义两个MySQL数据库连接
- php – 优化此SQL查询
- 使用php返回GROUP_CONCAT(‘列x’)值
- MYSQL保存特殊字符失败,用编码utf8mb4解决错误 Incorrect
- Mysql应用mysql获得60天前unix时间思路及代码
- php – 如何只选择第一个数字是从0到9的数字的行?
- javascript – 如果没有用户输入发送到数据库,是否存在任何
- mysql – 未定义的方法`eq’代表nil:nilClass with rails
- MYSQL教程MySQL几点重要的性能指标计算和优化方法总结