Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图从满足 SQL 中 where 子句的所有行中获取一个随机行。我正在使用以下 SQL,但得到了相应的错误。
SELECT * FROM xyz WHERE (long='0' AND lat='0') ORDER BY RAND() LIMIT 1
错误:#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'long='0' AND lat='0') ORDER BY RAND() LIMIT 1' 附近使用正确的语法
LONG 是保留字
SELECT * FROM xyz WHERE (`long`='0' AND lat='0') ORDER BY RAND() LIMIT 1
SELECT * FROM ( SELECT * FROM xyz WHERE (`long`='0' AND lat='0') ORDER BY DBMS_RANDOM.VALUE) LIMIT 1