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.
我有这个查询
"SELECT * FROM TABLE ORDER BY RAND() LIMIT 5"
但我不想显示 ID = 3 的数据
从这张表中......这可能与rand()功能有关吗?
rand()
示例:我在表格中有 10 张图像,id=1 id=2并且id=3 id=4 id=5.... 现在我想随机显示除图像之外的所有图像id=3
id=1
id=2
id=3
id=4
id=5
当然,只需添加一个WHERE语句(并删除LIMIT,因为您想要所有图像):
WHERE
LIMIT
SELECT * FROM `TABLE` WHERE `ID` != 3 ORDER BY RAND()