SELECT a.content, a.postdate, c.username
FROM (
表1 a
INNER JOIN 表2 b ON a.uid = b.uid
)
INNER JOIN 表3 c ON a.uid = c.uid
ORDER BY username, postdate DESC
LIMIT 50表1表2表三通过用户的uid关联如果想取得每一个用户的前2条表1记录,怎么取得啊
FROM (
表1 a
INNER JOIN 表2 b ON a.uid = b.uid
)
INNER JOIN 表3 c ON a.uid = c.uid
ORDER BY username, postdate DESC
LIMIT 50表1表2表三通过用户的uid关联如果想取得每一个用户的前2条表1记录,怎么取得啊
from tb A
where (select count(*) from tb where A.username=b.username and A.id>b.id)>2
[征集]分组取最大N条记录方法征集,及散分....
from tb A
where (select count(*) from tb b where A.username=b.username and A.id>b.id)<2
FROM 表1 a INNER JOIN 表2 b ON a.uid = b.uid
INNER JOIN 表3 c ON a.uid = c.uid
where 2>(select count(*) from 表1 where uid=a.uid and postdate>a.postdate)
ORDER BY username, postdate DESC
LIMIT 50