如何在 mysql 编辑中隐藏别名列 [英] How to hide an alias column in mysql EDITED

查看:38
本文介绍了如何在 mysql 编辑中隐藏别名列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是已经问过的一些问题的复制品,但我需要一些建议.

I know this is a replica of some question asked already, but i need some suggestion.

我知道 MySQL 的基础知识,我有一个查询来计算纬度和经度之间的距离,并根据我返回的最小距离来计算.

I know basics of MySQL, i have a query to calculate distance between latitude and longitude and based on minimum distance i am returning id's.

现在我不希望距离列作为我的查询结果.怎么做.

now i don't want the distance column as result of my query. How to do it.

这是我的查询.

    select cl.wp_id,( 3959 * acos( cos( radians(12.91841) ) * cos( radians( y(gproperty) ) ) * 
       cos( radians( x(gproperty)) - radians(77.58631) ) + sin( radians(12.91841) ) * 
       sin( radians(y(gproperty) ) ) ) ) AS distance 
from db1.geofeature gf, db2.c_loc cl where gf.o_type = 10 and cl.c_info_id = 23 
    and gf.o_id = cl.wp_id 
    having distance < 10 order by distance limit 10;

我只想显示我的 cl.wp 作为结果.怎么做.?

i want only my cl.wp to be displayed as result. How to do that.?

编辑现在我有 3 张桌子,如何加入它们.?

EDIT now i have 3 tables how to join them.?

select dlo.id,( 3959 * acos( cos( radians(12.9) ) * cos( radians( y(gproperty) ) ) * cos( radians( x(gproperty)) - radians(77.5) ) +sin( radians(12.9) ) * sin( radians(y(gproperty) ) ) ) ) AS distance from db1.gfeature dgf, db2.loc dlo, db2.cust dcu where gf.o_type = 6 and dcu.id = 240 and dgf.o_id = dlo.p_id having distance < 20 order by distance limit 10;

欢迎提出任何建议.

推荐答案

您可能想要使用子查询:

You would want to use a subquery:

select wp_id
from (select cl.wp_id,( 3959 * acos( cos( radians(12.91841) ) * cos( radians( y(gproperty) ) ) * 
             cos( radians( x(gproperty)) - radians(77.58631) ) + sin( radians(12.91841) ) * 
             sin( radians(y(gproperty) ) ) ) ) AS distance
      from db1.geofeature gf join
           db2.c_loc cl 
           on gf.o_type = 256 and cl.c_info_id = 146 and gf.o_id = cl.wp_id
    ) t
where distance < 10
order by distance
limit 10;

请注意,我还修复了连接语法以使用显式连接.

Notice that I also fixed the join syntax to use explicit joins.

这篇关于如何在 mysql 编辑中隐藏别名列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆