我有mysql数据库60k行,4列(ID,关键字,状态,Updet)并尝试使用此选择快速rand:
SELECT Keyword
FROM keyword AS r1
JOIN (
SELECT CEIL(RAND() *(SELECT MAX(id) FROM keyword)) AS id
) AS r2
WHERE r1.id >= r2.id
ORDER BY r1.id ASC LIMIT 1
但问题是我无法选择条件Updet ='已发布'并尝试
SELECT Keyword
FROM keyword AS r1
JOIN (
SELECT CEIL(RAND() *(SELECT MAX(id) FROM keyword)
) AS id) AS r2 ON r1.id >= r2.id
WHERE Updet='published'
ORDER BY r1.id ASC LIMIT 1
不工作,请帮忙..