mysql - SQL 从 2 个表更新 1 个表

标签 mysql sql logic

我需要一些创建更新查询的帮助。例如我有

select:(T1- table 1, T2- tables 2, Z1 -column from table 1, Z2 Column from table 2 etc)

Select * from T1,T2 where X1=X2 and Y1=Y2 and Z1=Z2 and Datea>=20160601 and Dateb<20160720 and B1=2 and C1=5 and D1=10 and E2 in (A+,A-, 22,33,44)

现在我想编写一个使用参数的更新

from where
update T1 set F1, G1 where

如何写出正确的条件?

最佳答案

update T1 set F1=10, G1=50 
where exist (Select F1, G1 
             from T1,T2 where X1=X2 
             and Y1=Y2 and Z1=Z2 
             and Datea>=20160601 
             and Dateb<20160720 
             and B1=2 
             and C1=5 
             and D1=10 
             and E2 in (A+,A-, 22,33,44))

您必须选择需要在 select 子句中更新的列。

还尝试先运行 select 语句,看看是否得到了您想要的结果

关于mysql - SQL 从 2 个表更新 1 个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39787816/

相关文章:

mysql - 如何分析 Amazon RDS 查询成本 (I/O)

mysql - 使用 View 从多个表中获取数据

c# - 为什么同一设计会得到两种不同的结果?

algorithm - 奶油沼泽拼图中的小 Sprite

mysql - 一个字段中有多个项目的表

php - 如何解决登录页面的错误

mysql - SQL 获取非规范化表中某指定信息对应的第一个字段

java - mybatis-插入事务

sql - Oracle Create Table AS和表注释以及列注释

c++ - 我的时间程序不会过载。为什么?