select * from table1 where id>(select MAX(id2) from table2)
发现没有记录返回,一直寻找其中的问题。
后来想到由于table2现在还未录入数据,所以id2的值为null,后来查了下,可以利用isnull( )函数来解决。修改如下:
select * from table1 where id>(select isnull(MAX(id2),0) from table2)