时间:2021-07-01 10:21:17 帮助过:13人阅读
第一段是不分页的
select T.ID ,TName.Name ,(select Count(UsingT.TID) from UsingT where UsingT.TID=T.ID) as LinkCountfrom T inner join TName on T.TNameID = TName.ID and TName.Name like @tname order by Name asc; <=重点在这里
第二段是分页的
select T.ID ,TName.Name ,(select Count(UsingT.TID) from UsingT where UsingT.TID=T.ID) as LinkCountfrom T inner join TName on T.TNameID = TName.ID where T.ID in (select ID from <这是加壳>(select T.ID from T inner join TName on T.TNameID=TName.ID and TName.Name like @Tname order by Name asc <=重点在这里limit @start,@count)as x); <这是加壳>
但是order by后的两段结果顺序就不一样?比较奇怪
<顺便网友们在帮帮忙,评评我这第二段,效率是上升还是下降?本人新手>