表
**Posts:**
| id | userID | title |
| 1 | 6 | text1 |
| 2 | 5 | text2 |
| 3 | 8 | text3 |
**Votes:**
| id | userID | postID |
| 1 | 6 | 2 |
| 2 | 5 | 2 |
| 3 | 8 | 1 |
| 4 | 8 | 3 |
| 5 | 8 | 2 |
**Sql**
SELECT p.*,(SELECT count(*) FROM votes AS v WHERE v.postID=p.id AS count)
FROM posts AS p WHERE p.userID = 6
ORDRER BY count DESC
这将成为前 3 名列表,但如果列表中有类似的内容,我希望名列前茅
Your position is 3
如果用户登录。如何计算用户位置?基于他的帖子有多少票