我有这个问题:
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.latitude-$tetagmenh)*
(v2.latitude-$tetagmenh)
),
sqrt(
(v3.longitude-$tetmimenh)*
(v3.longitude-$tetmimenh)+
(v3.latitude-$tetagmenh)*
(v3.latitude-$tetagmenh)
),
sqrt(
($tetmimenh-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";
答案 0 :(得分:0)
试试这段代码:
SELECT v2.longitude AS something,2*v2.longitude AS something2 FROM points AS v2
答案 1 :(得分: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.latitude-$tetagmenh)*
(v2.latitude-$tetagmenh)
),
sqrt(
(v3.longitude-$tetmimenh)*
(v3.longitude-$tetmimenh)+
(v3.latitude-$tetagmenh)*
(v3.latitude-$tetagmenh)
),
sqrt(
($tetmimenh-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