select * from protype where id in (select top {0} id from (select top {1} id from protype where tid=" + id + " order by id desc) as t order by t.id desc) order by id desc
请看上面的一条sql语句,经测试执行顺序为当然是在access中,因为,我觉得sqlserver中可能会不一样!
①select top {1} id from protype where tid=" + id + " order by id desc
②select top {0} id from (select top {1} id from protype where tid=" + id + " order by id desc) as t order by t.id desc)
③select * from protype where id in (select top {0} id from (select top {1} id from protype where tid=" + id + " order by id desc) as t order by t.id desc) order by id desc
括号的优先级还是体现出来了
select * from protype where id in (select top {0} id from (select top {1} id,sort from protype where tid=" + id + " order by sort desc) as t order by t.sort) order by sort desc
这条语句竟然还能正常执行!