简体   繁体   English

SQL查询错误#1064

[英]SQL query error #1064

So I have this query: 所以我有这个问题:

SELECT 
   t1.password 
FROM Session AS t1 
INNER JOIN Locations AS t2 ON 
    t2.id = t1.location_id AND 
    SQRT( POWER( CONVERT(t2.longitude,float(10)) - 132.456, 2) + 
        POWER( CONVERT(t2.latitude,float(10)) - 132.456, 2) ) < 100 
WHERE t1.end_distribution = 0 AND t1.end_session = 0

and I get this: 我明白了

1064 - You have an error in your SQL syntax; 1064 - 您的SQL语法出错; check the manual that corresponds to your MySQL server version for the right syntax to use near 'float(10)) - 132.456, 2) + POWER( CONVERT(t2.latitude,float(10)) - 132.456, 2) )' at line 13 检查与MySQL服务器版本对应的手册,以便在'float(10)附近使用正确的语法 - 132.456,2)+ POWER(CONVERT(t2.latitude,float(10)) - 132.456,2(2))'at第13行

Use 采用

CONVERT(t2.longitude, float(10))

MySQL CONVERT SYNTAX MySQL CONVERT SYNTAX

UPDATE UPDATE

Depending on documentation above you can't convert expression to type float, use decimal instead. 根据上面的文档,您不能将表达式转换为float类型,而是使用decimal。

CONVERT(t2.longitude, decimal(10))

You've got an invalid specification for the type on the CONVERT function. 你在CONVERT函数上的类型有一个无效的规范。 FLOAT(10) is not valid. FLOAT(10)无效。 It looks like your best alternative will be to use DECIMAL . 看起来您最好的替代方案是使用DECIMAL

From the MySQL Reference Manual: http://dev.mysql.com/doc/refman/5.5/en/cast-functions.html 从MySQL参考手册: http//dev.mysql.com/doc/refman/5.5/en/cast-functions.html

<snip> <剪断>

The type for the result can be one of the following values: 结果的类型可以是以下值之一:

BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]

</snip> </剪断>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM