我的 order by 为什么总是不生效呢?

一休宗纯 2010-08-02 10:57:45
sql = "select tDept.dept_seq,tDept.dept_name,tUser.name,day(tGrade.pub_date) as pub_day, tGrade.* from tDept,tUser,tGrade where tDept.id=tUser.dept_id and tUser.id=tGrade.user_id and year(pub_date)=2010 and month(pub_date)=8 ORDER BY tDept.dept_seq"

我发现不管我加不加 order by 都没有什么效果,请有识之士帮我看一看.
...全文
394 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
rains0929 2010-08-03
  • 打赏
  • 举报
回复
你的语句没有问题,建议在查询分析器中执行
ACMAIN_CHM 2010-08-03
  • 打赏
  • 举报
回复
sych888 2010-08-03
  • 打赏
  • 举报
回复
验证SQL语句的正确性,最好是在查询分析器里面执行一下
ask_chang 2010-08-03
  • 打赏
  • 举报
回复
select b.dept_seq,b.dept_name,a.name,day(c.pub_date) as pub_day,c.*
from tUser a
inner join tDept b on a.ept_id=b.id
inner join tGrade c on a.id=c.user_id
where year(c.pub_date)=2010 and month(c.pub_date)=8
order by b.dept_seq

给你换一种写法
Ellen_Tang 2010-08-03
  • 打赏
  • 举报
回复
默认是升序的
micro2000 2010-08-02
  • 打赏
  • 举报
回复
这种一眼看上去就可以确认没有问题,应该立即怀疑别的地方。
luodx1021 2010-08-02
  • 打赏
  • 举报
回复
语句没有发现问题,是按照表tDept的dept_seq字段升序排序的。
你可以把语句放到查询分析器里面,查一下就知道结果了。
百年树人 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 dengxm 的回复:]
我发现其实是我的别的地方处理的问题,这个SQL原来是正确的
[/Quote]

呵呵
一休宗纯 2010-08-02
  • 打赏
  • 举报
回复
我发现其实是我的别的地方处理的问题,这个SQL原来是正确的
hokor 2010-08-02
  • 打赏
  • 举报
回复

不知道你哟啊达到什么效果?排序没有问题,按照第一列升序排序。

34,592

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧