我试图从满足SQL中where子句的所有行中获取一个随机行。我使用以下SQL但收到相应的错误。
SELECT * FROM xyz WHERE (long='0' AND lat='0') ORDER BY RAND() LIMIT 1
错误: #1064 - 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'long ='0'和lat ='0'附近使用正确的语法。)ORDER BY RAND()LIMIT 1'在第1行
答案 0 :(得分:2)
LONG是保留字
SELECT * FROM xyz WHERE (`long`='0' AND lat='0') ORDER BY RAND() LIMIT 1
答案 1 :(得分:0)
SELECT *
FROM ( SELECT *
FROM xyz
WHERE (`long`='0' AND lat='0')
ORDER BY DBMS_RANDOM.VALUE) LIMIT 1