mysql 5.7Expression #1 of ORDER BY clause is not in SELECT list

 

java.sql.SQLException: Expression #1 of ORDER BY clause is not in SELECT list, references column 'amc.ti.create_time' which is not in SELECT list; this is incompatible with DISTINCT

 

  今天遇到一个问题,一个sql可以在mysql5.6运行,不能在mysql5.7运行。百度说,可以修改my.cnf,但是mac的mysql没有这配置。继续百度,

http://bbs.csdn.net/topics/391878172page=1,

 http://blog.sina.com.cn/s/blog_4f925fc30102e0ot.html

 

上面句子正确写法:SELECT T.NAME FROM UNIT T WHERE ROWNUM < 10 ORDER BY T.UNITNO;

                  或者                 

                  SELECT DISTINCT T.NAME,T.UNITNO FROM UNIT T WHERE ROWNUM < 10 ORDER BYT.UNITNO;

 

【注】:加DISTINCT后是把数据先放到一个DISTINCT后的临时集合里然后再进行排序。

 

 

你可能感兴趣的:(mysql,5.7)