(SELECT * FROM table1
INNER JOIN table2
ON table1.id = table2.id)
AS t1
JOIN (SELECT ROUND(RAND() * (SELECT MAX(table1.id) FROM table1)) AS id)
AS t2
WHERE t1.id >= t2.id
LIMIT 1)
我尝试使用RAND()
max(id)
获取随机 mysql 结果,但得到一个#1064
错误。
#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 'AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(table1.id) FROM table1))' at line 1
问题出在哪里?谢谢。