SQL CROSS APPLY 用法
有两个表,分类表,和文件表
两个表的关联地段是分类ID
要求,查询每个分类表下面最后更新的三条文件表数据
select * from Category as c cross apply (select top 3 * from FileCategory as rc where c.Id = CategoryId order by rc.UpdateTime desc) as rc
有两个表,分类表,和文件表
两个表的关联地段是分类ID
要求,查询每个分类表下面最后更新的三条文件表数据
select * from Category as c cross apply (select top 3 * from FileCategory as rc where c.Id = CategoryId order by rc.UpdateTime desc) as rc