开发者

mysql order by not included 0

i have query not working for order by

(SELECT * FROM products WHERE ParentID=139 AND `Position`!=0 AND 
        (
        (69.1 * (lattitude- 53.84787)) *
        (69.1 * (lattitude- 53.84787))
        ) + (
        (69.1 * (longitude- (-1.77684)) * COS(53.84787 / 57.3)) *
        (69.1 * (longitude- (-1.77684)) * COS(53.84787 / 57.3))
        ) <  POW(5, 2) ORDER BY `Position` ASC) 

        UNION 

        (SELECT * FROM products WHERE ParentID=139 AND `Position`=0 AND 
        (
        (69.1 * (lattitude- 53.84787)) *
        (69.1 * (lattitude- 53.84787))
        ) + (
        (69.1 * (longitude- (-1.77684)) * COS(53.84787 / 57.3)) *
        (69.1 * (longitude- (-1.77684)) * COS(53.84787 / 57.3))
        ) <  POW(5, 2) ORDER BY
        ((
                (69.1 * (lattitude- 53.84787)) *
                (69.1 * (lattitude- 53.84787))
        ) + (
        (69.1 * (longitude- (-1.77684)) * COS(53.84787 / 57.3)) *
        (69.1 * (longitude- (-1.77684)) * COS(53.84787 / 57.3))
        )),`Position` ASC )    

it's not give me the order by position result.

i want that first the all result should come with position!=0 and then all 0 position re开发者_开发问答cords.


There is no point in using ORDER BY clauses in intermediate queries or subqueries. MySQL will not care to keep such order on the final result set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜