sql where id 上的子查询

nol*_*ogo 2 sql

我很难理解这个问题。我想转换以下sql语句(从oracle转换为sql)以返回所有记录,而不是单个记录。

select * 
from table_1 
where ID = @myid and MyMonth = (select max (MyMonth) from table2 where ID = @myid)
Run Code Online (Sandbox Code Playgroud)

正如我所说,我想返回所有不针对 @myid 给定值的内容的摘要。

删除其中的 ID 部分不会返回任何内容。

谢谢,

mor*_*rja 6

尝试这个:

select * 
from table_1 t1
where t1.MyMonth = (select max (t2.MyMonth) from table2 t2 where t1.ID = t2.ID)
Run Code Online (Sandbox Code Playgroud)