• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase
您的位置:首页 > 数据库 >Mysql > mysql多表join时候update更新数据的方法

mysql多表join时候update更新数据的方法

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-05

匿名通过本文主要向大家介绍了join,update等相关知识,希望本文的分享对您有所帮助

如果item表的name字段为''就用resource_library 表的resource_name字段前面加上字符串Review更新它,他们的关联关系在表resource_review_link中。

sql语句:
代码如下:
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.
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Mysql跨表更新 多表update sql语句总结
  • 深入理解mysql之left join 使用详解
  • mysql not in、left join、IS NULL、NOT EXISTS 效率问题记录
  • mysql多表join时候update更新数据的方法
  • MySQL JOIN之完全用法
  • 超详细mysql left join,right join,inner join用法分析
  • Mysql中的join操作实例分享
  • MySQL中关于Join的使用示例分享
  • sql中用JOIN USING如何简化JOIN ON的实例
  • Mysql中关于连接(join)查询详解

相关文章

  • 2018-12-05Oracle EXTRACT()函数
  • 2018-12-05access数据库用sql语句添加字段,修改字段,删除字段
  • 2018-12-05SQLserver中字符串查找功能patindex和charindex的区别
  • 2018-12-05MySQL易学易用之MYSQL不为人知的特性
  • 2017-05-11在MySQL中使用LIMIT进行分页的方法
  • 2017-05-11Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结
  • 2017-05-11用MyEclipse配置DataBase Explorer(图示)
  • 2018-12-05mysql进阶(十五) mysql批量删除大量数据
  • 2018-12-05分区字段入门教程:10个分区字段零基础入门教程推荐
  • 2018-12-05在SQL Server数据库中为标识(IDENTITY)列插入显式值

文章分类

  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase

最近更新的内容

    • MySQL的Query Cache原理分析
    • mysql 导出select语句结果到excel文件遇到问题及解决方法_MySQL
    • sql注入实例以及如何防sql注入
    • mySQL中LEN()与DATALENGTH()的区别
    • Oracle数据表分区的策略
    • mysql数据库应付大流量网站的的3种架构扩展方式介绍
    • SQL事务用法begin tran,commit tran和rollback tran的用法
    • sql 2005不允许进行远程连接可能会导致此失败的解决方法
    • 使用SqlBulkCopy时应注意Sqlserver表中使用缺省值的列
    • mysql delete limit 使用方法详解

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有