晕死了!这么简单的Sql我咋不知道该怎么写了?

kellyfly 2003-09-13 03:14:00
在A表中,查找字段ID最大的.并得到相应最大ID的Name等.该怎么写啊?一句Sql写完.

我晕死了!!!这么简单的,我竟然不知道了.....

各位帮忙!
...全文
42 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
feiqinfeiwhw 2003-09-13
  • 打赏
  • 举报
回复
这个方法:也可以的:如果你的id是数字可以用这种方法:
select top 1 name from 表A order by id desc
如果不是用:
select top 1 name from a order by value(id) desc
feiqinfeiwhw 2003-09-13
  • 打赏
  • 举报
回复
select id,name from a,(select max(id) as strid from a) as b where a.id=b.strid

这样不就行了!
zjcxc 2003-09-13
  • 打赏
  • 举报
回复
select top 1 name from 表A order by id desc
armu80830 2003-09-13
  • 打赏
  • 举报
回复
select id,name from A where id in(select max(id) from A)

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧