更新表语法:查询在mysql中工作,但在oracle或mssql中不工作

更新表语法:查询在mysql中工作,但在oracle或mssql中不工作,mysql,sql,sql-server,oracle,Mysql,Sql,Sql Server,Oracle,我想用t_三中的对应值更新t_on.f6,该值取决于连接。这个查询在mysql中运行得很好,但是我得到了 甲骨文中的错误 ORA-00971:缺少集合关键字 在MSSQL中 查询中出错:“t1”附近的语法不正确 对此我能做些什么呢?我永远记不起各个子句出现的顺序,但这是一个大致相同的顺序 update t_one t1 join t_two t2 on (t2.f1 = t1.f1) join t_three t3 on (t1.f4 = t3.f4 and t2.f5 = t3.f5) s

我想用t_三中的对应值更新t_on.f6,该值取决于连接。这个查询在mysql中运行得很好,但是我得到了

甲骨文中的错误

ORA-00971:缺少集合关键字

在MSSQL中

查询中出错:“t1”附近的语法不正确


对此我能做些什么呢?

我永远记不起各个子句出现的顺序,但这是一个大致相同的顺序

update t_one t1 
join t_two t2 on (t2.f1 = t1.f1)
join t_three t3 on (t1.f4 = t3.f4 and t2.f5 = t3.f5) 
set t1.f6 = t3.f6 
where t1.f6 is null

您可能不需要
set
where
子句中的
t1
别名,但它们可能不会有任何影响。

您希望SQL Server使用类似的别名:

update t1 
set t1.f6 = t3.f6 
from t_one t1
join t_two t2 on (t2.f1 = t1.f1)
join t_three t3 on (t1.f4 = t3.f4 and t2.f5 = t3.f5) 
where t1.f6 is null
UPDATE t1 
   SET t1.f6 = t3.f6 
  FROM t_one t1 
       INNER JOIN t_two t2 ON t2.f1 = t1.f1
       INNER JOIN t_three t3 ON t1.f4 = t3.f4 AND t2.f5 = t3.f5 
 WHERE t1.f6 is null
在SQL Server中:

update t1 
set t1.f6 = t3.f6 
from t_one t1
join t_two t2 on (t2.f1 = t1.f1)
join t_three t3 on (t1.f4 = t3.f4 and t2.f5 = t3.f5) 
where t1.f6 is null
UPDATE t1 
   SET t1.f6 = t3.f6 
  FROM t_one t1 
       INNER JOIN t_two t2 ON t2.f1 = t1.f1
       INNER JOIN t_three t3 ON t1.f4 = t3.f4 AND t2.f5 = t3.f5 
 WHERE t1.f6 is null

不同风格的SQL类似于不同的编程语言:它们可能相似,但永远不会相同。实际上,您要求我们将一些代码从一种语言转换为另一种语言。对于Oracle:UPDATE aliasName SET table.column=表中的值一个aliasName内部联接表二个aliasName.ColumnX=表二个ColumnY,等等@pmbAustin-用于哪个DBMS?这不会在Oracle.SQL Server中运行。。。任何版本。