嘿大家,我不太确定如何以谷歌搜索的形式描述这个,所以我决定来这里看你们是否可以提供帮助.基本上,我想知道如何将以下伪sql转换为实际的mysql查询:
Select one random row
from `posts`
where (the user's id, which is supplied by the script) is not found in the `votes` table
with a post id of (the selected post's id).
Run Code Online (Sandbox Code Playgroud)
如果你能提供帮助,非常感谢你.
像这样的东西:
SELECT *
FROM Posts
WHERE Posts.ID NOT IN (
SELECT Votes.PostID FROM Votes WHERE Votes.UserID=@UserID
)
ORDER BY Rand()
LIMIT 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
95 次 |
| 最近记录: |