gpt4 book ai didi

mysql order by 不包括0

转载 作者:行者123 更新时间:2023-11-29 14:43:35 24 4
gpt4 key购买 nike

我的查询不适用于订单

(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 位置记录。

最佳答案

在中间查询或子查询中使用 ORDER BY 子句是没有意义的。 MySQL 不会在意在最终结果集上保留这样的顺序。

关于mysql order by 不包括0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7484872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com