您的位置:首页 > 博客中心 > 数据库 >

sql表连接去重复查询

时间:2022-03-14 02:26

查询公司与公司最新刷新的一条信息

    select  t1.userid,t1.id,t1.title,t1.RegType,t1.Salary,t1.SubjectID,t1.RefreshTime,t2.name,t2.logo,t2.[address],t2.CreateTime 
    from info t1 inner join   
    companyinfo t2 on t1.userid=t2.id
    where t1.id in 
    (
        select top 1 info.id from info where userid = t1.userid order by refreshtime desc
    ) 
    and t1.userid in
    (
        select  distinct userid from PackageRecord where PackagePid=1 and getdate()<endtime
    )

 

热门排行

今日推荐

热门手游