sql - Hiding alias column in MySQL -
it might repeated question need help. new mysql.
here problem.
i have query calculate distance between latitude , longitude. based on distance order have return id's.
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))))) distance db1.gfeature dgf, db2.loc dlo, db2.cust dcu gf.o_type = 6 , dcu.id = 240 , dgf.o_id = dlo.p_id having distance < 20 order distance limit 10;
which returns
+------+-----------------------+ | id | distance | +------+-----------------------+ | 101 | 0.00025714756425665 | | 199 | 0.10971525612556807 | | 722 | 0.22772618588406165 | +------+-----------------------+
but need id column displayed. asked same-question yesterday. using three tables data. confused in joining 3 tables.
can suggest me.?
i tried way
select id ( 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) ) ) ) ) distance db1.gfeature dgf join db2.cust dcu, db2.loc dlo on dgf.o_type = 6 , dcu.id = 10 , dgf.o_id = dlo.w_id ) t distance < 10 order distance limit 10;
but getting syntax error near "on..."
maybe this. use subquery achieve.
select s.id (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))))) distance db1.gfeature dgf, db2.loc dlo , db2.cust dcu gf.o_type = 6 , dcu.id = 240 , dgf.o_id = dlo.p_id having distance < 20) s order s.distance limit 10;
Comments
Post a Comment