道路中心虚线尺寸:关于sql数据库查询代码!

来源:百度文库 编辑:神马品牌网 时间:2024/05/09 11:59:44
查找数据库中某字段的最后一个数据并返回数据,如何写代码啊?
如果在asp中,应如何提取查询结果并显示

如果你是用的MS SQL Server 2000,可以如此
"select top 1 id from table_name where 1=1 order by id desc"
能满意?

select max(递增的字段) from xxx
然后取出这值
select 某字段 from xxx where 递增的地段=刚才取出来的值

假设你这个表有两个字段id(自动增长),name(姓名),现在要取姓名最后一个数据,可以这样写:

select top 1 name from tablename order by id desc