我正在尝试从表“用户”中获取 10 个随机行,以及从表“Profile_pictures”中获取匹配的个人资料图片。
到目前为止我的查询:
SELECT u.id, u.username, u.status, p.file_name
FROM users AS u, profile_pictures AS p
WHERE p.status = 1 AND u.status != 3 AND u.status != 4
AND RAND()<(SELECT ((1/COUNT(*))*10) FROM users AS u)
GROUP BY u.id
ORDER BY RAND()
LIMIT 7
问题是它为所有行获取相同的个人资料图片。
我真的,真的希望你能帮助我。