MySQL社区

标题: 求大神帮忙看下 not exists 和 order by 结合无法排序 [打印本页]

作者: 29584697    时间: 2016-7-6 18:19
标题: 求大神帮忙看下 not exists 和 order by 结合无法排序
  1. select stuId,stuName from student student  where  campusId=1 and  stuAdvisor=108 and   not exists  (select stuId from stu_class stu_Class where classId=515 and student.stuId=stu_Class.stuId)  order by stuName  limit 0,10
复制代码
not exists 和order by 结合,查询结果没有按照 stuName排序,请大神指教下,拜谢
作者: yflower    时间: 2016-8-3 17:57
你的 order by 后面没有加排序的类型:asc或者desc

参考自:
MySQL如何优化ORDER BY http://www.data.5helpyou.com/article246.html
作者: pztx1992    时间: 2016-9-8 11:10
首先是升序的,sql语句是没有问题的,你可以先在数据库里面查询




欢迎光临 MySQL社区 (http://www.mysqlpub.com/) Powered by Discuz! X3.2