0

我有这个查询:

SELECT v2.longitude AS something FROM points AS v2

现在我想做这样的事情:

SELECT v2.longitude AS something,2*something FROM points AS v2

但它失败了

points.longitude是一个浮点数

我怎样才能解决这个问题?

编辑-这是当前查询的示例:

$query="
SELECT 
v2.longitude AS xa,
v2.latitude AS ya,
v3.longitude AS xb,
v3.latitude AS yb, 
(yb-ya)/(xb-xa) AS l,
-1/l AS l_katheto,
(l*xa-l_katheto*$tetmimenh+ya-y1)/(l_katheto-l) AS x_tomh, 
l*(x_tomh-xa)+ya AS y_katheto,
min(
    sqrt(
        (v2.longitude-$tetmimenh)*
        (v2.longitude-$tetmimenh)+
        (v2.latit‌​ude-$tetagmenh)*
        (v2.latitude-$tetagmenh)
    ),
    sqrt(
        (v3.longitude-$tetmimenh)*
        (v3.long‌​itude-$tetmimenh)+
        (v3.latitude-$tetagmenh)*
        (v3.latitude-$tetagmenh)
    ),
    sqrt(
        ($tetmi‌​menh-x_tomh)*
        ($tetmimenh-x_tomh)+
        ($tetagmenh-y_tomh)*
        ($tetagmenh-y_tomh)
    )
) 
FROM 
segments AS v1 
JOIN points AS v2 ON v1.from_point=v2.point_id 
JOIN points AS v3 ON v3.point_id=v1.to_point";
4

2 回答 2

0

我不确定您在这里要完成什么,但鉴于您在之前的评论中给出的查询,我只能评论我目前的理解。

您对@Jocelyn 的评论中的查询

SELECT 
v2.longitude AS xa,
    /* you can use xa2 for the rest of your calcs */
2*(v2.longitude) as xa2,
v2.latitude AS ya,
v3.longitude AS xb,
    /* if you need it for the other long as well */
2*(v3.longitude) as xb2,
v3.latitude AS yb, 
(yb-ya)/(xb-xa) AS l,
    /* BTW, the (l) makes this and the next few line hard to read */
-1/l AS l_katheto,
    /* is this a negative inverse? */
(l*xa-l_katheto*$tetmimenh+ya-y1)/(l_katheto-l) AS x_tomh, 
l*(x_tomh-xa)+ya AS y_katheto,
min(
    sqrt(
        (v2.longitude-$tetmimenh)*
        (v2.longitude-$tetmimenh)+
        (v2.latit‌​ude-$tetagmenh)*
        (v2.latitude-$tetagmenh)
    ),
    sqrt(
        (v3.longitude-$tetmimenh)*
        (v3.long‌​itude-$tetmimenh)+
        (v3.latitude-$tetagmenh)*
        (v3.latitude-$tetagmenh)
    ),
    sqrt(
        ($tetmi‌​menh-x_tomh)*
        ($tetmimenh-x_tomh)+
        ($tetagmenh-y_tomh)*
        ($tetagmenh-y_tomh)
    )
) 
FROM 
segments AS v1 
JOIN points AS v2 ON v1.from_point=v2.point_id 
JOIN points AS v3 ON v3.point_id=v1.to_point
于 2012-07-07T17:39:58.503 回答
0

试试这个代码:

SELECT v2.longitude AS something,2*v2.longitude AS something2 FROM points AS v2
于 2012-07-07T12:58:48.857 回答