hibernate 查询表中最后一条语句的hql怎么写?!

来源:百度知道 编辑:UC知道 时间:2024/05/05 23:43:52
rt
明显没...不然就不用提问了..
=======================
mysql 用count函数可以取得表中所有记录数.
这所有记录可以作为最后一条记录的id吗?

select * from table
where rownum<(select count(*)+1 from table)
minus
select * from table
where rownum<(select count(*) from table)

也可以简化为
select * from table
minus
select * from table
where rownum<(select count(*) from table)
效果是一样的

切记rownum是伪列 只能用<

顺便给你求第X行的通用SQL语句
select * from table where rownum<X+1
minus
select * from table where rownum<X

有id 没,有的话 id within(select max(id) from ....)