全部博文(413)
分类: Mysql/postgreSQL
2014-03-31 21:38:52
下面的sql语句报错:sql错误 (1221) :Incorrect usage of union and order by需要修改成如下:点击(此处)折叠或打开
- select * from guojia_jingjia where guanzhi='xxx' order by (aaa+bbb+ccc) desc limit 1
- union
- select * from guojia_jingjia where guanzhi in (...) order by bbb desc limit 4
- union
- select * from guojia_jingjia where guanzhi in (...) order by aaa desc limit 4
点击(此处)折叠或打开
- select * from (select * from (select * from (select * from guojia_jingjia where guanzhi='xxx' order by (aaa+bbb+ccc) desc limit 1)t1
- union
- select * from (select * from guojia_jingjia where guanzhi in (...) order by bbb desc limit 4) t2
- union
- select * from guojia_jingjia where guanzhi in (...) order by aaa desc limit 4