mysql order by union似乎不起作用 [英] mysql order by with union doesn't seem to work
本文介绍了mysql order by union似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的查询
(SELECT * FROM `jokes` WHERE `flags` < 5 AND (`title` LIKE "%only three doors%" OR `joke` LIKE "%only three doors%") ORDER BY `ups` DESC,`downs` ASC)
UNION
(SELECT * FROM `jokes` WHERE `flags` < 5 AND (`title` LIKE "%only%" OR `joke` LIKE "%only%") ORDER BY `ups` DESC,`downs` ASC)
UNION
(SELECT * FROM `jokes` WHERE `flags` < 5 AND (`title` LIKE "%three%" OR `joke` LIKE "%three%") ORDER BY `ups` DESC,`downs` ASC)
UNION
(SELECT * FROM `jokes` WHERE `flags` < 5 AND (`title` LIKE "%doors%" OR `joke` LIKE "%doors%") ORDER BY `ups` DESC,`downs` ASC)
LIMIT 0, 30
由于某种原因,它似乎并没有按照升序或降序排序……它只是按照结果在数据库中的自然顺序将其扔回给我.
For some reason it doesn't seem to order by ups or downs...it just tosses me back the results in the order they are naturally in the database.
当我只将其缩减为一个查询时,它可以正常工作,但是除此之外,它似乎忽略了它.
When I cut it down to only one query, it works fine, but other than that, it seems to ignore it.
我也不想按整个结果排序,否则我会放LIMIT 0,30 Order By blah
I also don't want to order by the entire results, or I would have put LIMIT 0,30 Order By blah
推荐答案
查看全文