为多个数据库系统编写SQL查询

时间:2018-01-24 16:04:55

标签: mysql sql sql-server oracle11g

我想编写一个可以在多个数据库系统(Mysql,Sql Server,SQLLite)上运行的Sql查询。

Sql Query:

UPDATE table2 set table2.Name = table1.Name" join table1 on table2.Id = table1.Id 

1 个答案:

答案 0 :(得分:1)

update table2 
set table2.name = (select min(table1.name) 
                   from table1 
                   where table1.id = table2.id);

如果{1}}在表1中是唯一的,则id可以仅由min(name)替换。

相关问题