求一个select语句写法

MySql 码拜 8年前 (2016-02-03) 1080次浏览
求一个select语句写法
如图表:TBL1
求表TBL1中type为1中ID最大的一条数据,select语句改怎么写
要求要是一条sql语句
解决方案

70

select * from
TbL1
where
id in
(
select max(ID) as ID from TBL1 where Type =1
)

30

select *
from TBL1 t
where type=1
and not exists (select 1 from TBL1 where type=1 and ID>t.ID )

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求一个select语句写法
喜欢 (0)
[1034331897@qq.com]
分享 (0)