我的查询不适用于
的订单(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 )
它没有按位置结果给我订单。
我希望首先所有结果都应该位置!= 0然后是所有0位置记录。
答案 0 :(得分:1)
在中间查询或子查询中使用ORDER BY
子句毫无意义。 MySQL不会在最终结果集上保留这样的顺序。