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; 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
Use
CONVERT(t2.longitude, float(10))
UPDATE
Depending on documentation above you can't convert expression to type float, use decimal instead.
CONVERT(t2.longitude, decimal(10))
You've got an invalid specification for the type on the CONVERT function. FLOAT(10)
is not valid. It looks like your best alternative will be to use DECIMAL
.
From the MySQL Reference Manual: 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.