数据库-我写了一段mysql查询,但是两段order by的顺序却不一样,求助
程序员文章站
2022-05-16 22:40:41
...
mysql数据库
第一段是不分页的
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
但是order by后的两段结果顺序就不一样?比较奇怪