我需要一些创建更新查询的帮助。例如我有
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/