MariaDB 和 MySql 对子查询排序不样的处理,求大神帮忙支招
本帖最后由 errya 于 2016-6-15 22:05 编辑先贴上我的数据以下数据是在MariaDB 下测试
select id,categoryid,top from lbdc_contentbind where id in (6,7) order by id desc;+----+------------+-----+
| id | categoryid | top |
+----+------------+-----+
|7 | 114 |42 |
|7 | 113 |39 |
|7 | 112 | 1 |
|6 | 114 |54 |
|6 | 113 |62 |
|6 | 112 |61 |
+----+------------+-----+
id 是我的文章的id, categoryid 是我栏目id ,top该文章在该栏目下的权重。现在我的需求是,查找出114,113,112栏目下所有的文章,并获取最高的权重。
我的sql语句是这样的
select * from (select id,categoryid,top from lbdc_contentbind where categoryid in (114,113,112)order by top desc) b group by id出来的数据是这样的,
+----+------------+-----+
| id | categoryid | top |
+----+------------+-----+
|6 | 112 |61 |
|7 | 112 | 1 |
+----+------------+-----+
貌似和我想象中的有点差别,不应该是|6 | 112 |62 |和|7 | 114 |42 | 么
加入更多的数据测试,发现MariaDB 的 子查询排序是无效的, 于是我又把相同的数据导入到MySql中测试
却得到了正确的结果。
求大神帮忙看一下,这是MariaDB数据库本身的设定,还是配置的问题,或者是我打开的方式不对。谢谢。
解决了吗 求解?
页:
[1]