(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
錯誤。MySQL的內部連接隨機語法錯誤
#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
問題出在哪裏?謝謝。
這是整個查詢? –