mysql多表join时候update更新数据的方法
发布时间:2024-01-15 12:56:37
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.
猜你喜欢
- 1. 安装Pyechartspip install pyecharts2. 图表基础2.1 主题风格添加主题风格使用的是 InitOpts(
- 之前一直傻傻分不清(n,1)和(n,)之间的区别,这里做一下总结,希望度过此文章的小伙伴都能明白。例如如果我们创建一个包含10个整型数的数组
- 从一头雾水到模模糊糊,不明原理,暂时记录一下1.安装Qtcratersudo pacman -S qtcreater2.打开Qtcrater
- Python之Selenium(自动化浏览器测试)1.安装seleniumpip install selenium -i https://p
- 英文的文档在这里,详细全面,本文仅为自己的学习笔记,只是试图通过转述加深自己的学习,不详细不全面。由于浏览器之间的差异,所以在JS中监听事件
- 本文实例讲述了PHP依赖注入原理与用法。分享给大家供大家参考,具体如下:引言依然是来自到喜啦的一道面试题,你知道什么是依赖注入吗?依赖注入(
- 一、原理1.图片必须具有经纬度信息2.经纬度格式转换2.1 GPS点坐标的两种表示方式(误差还是有的)2.1.1 十进制换度分秒例:经纬度1
- 导入相关库import time1. 时间戳1.1 time.time()time.time()可以得到的是 时间戳 。即 1970年1月1
- 一、Ajax简介Ajax被认为是(Asynchronous JavaScript and XML)的缩写,允许浏览器与服务器通信而无需刷新当
- 在 Python 中,一般情况下我们可能直接用自带的 logging 模块来记录日志,包括我之前的时候也是一样。在使用时我们需要配置一些 H
- 今天用要django传值给模板, 然后需要用js处理一下.特此记录.用json.dumps()方法将值传给模板.import json re
- 1.默认已经有python环境和vscode2.pip安装PyQt5执行命令:pip install PyQt5pip install Py
- var getWindow = function(obj) { var&nbs
- Python-类属性,实例属性,类方法,静态方法,实例方法类属性和实例属性#coding:utf-8class Student(object
- 1.打开VS CODE,若要使用SVN需要下载相应的插件。2.点击左侧,在上方搜索扩展,输入“chinese”,点击第一个插件安装,可以安装
- 昨天晚上睡觉前突然想到的,在此记一笔。传统方式以前我们做文章系统或新闻发布系统的时候,做文章内链(标签)的时候,通常是通过以下方式来实现的:
- 本文实例讲述了Python实现读取字符串按列分配后按行输出。分享给大家供大家参考,具体如下:问题:输入一个字符串和一个数字,数字代表分为几行
- 只能是一些限定的东西运行代码框ENTER键可以让光标移到下一个输入框 <input onkeydown="if(event.
- 目标是想把在服务器上用pytorch训练好的模型转换为可以在移动端运行的tflite模型。最直接的思路是想把pytorch模型转换为tens
- ttk控件的width-height设置tkinter中窗口,框架容器,控件如果不设置宽度高度,则会根据其中的内容自动设置宽度高度框架容器设