读书人

比如表中有好多数据小弟我想查最后一

发布时间: 2012-03-19 22:03:05 作者: rapoo

比如表中有好多数据,我想查最后一条,但是这个表对信息没有编号,我要怎么查最后一条的信息呢??
多谢


[解决办法]
--如何从表中用SELECT语句提取最后1条数据

SQL code
declare @num as intselect @num = count(*) from authorsset @num = @num - 1declare @sql as varchar(200)set @sql = 'select * from authors where au_id not in (select top ' + cast(@num as char) + ' au_id from authors)'exec (@sql) 

读书人网 >SQL Server

热点推荐