sql查询语句问题
一个供应表 id 会员id 信息标题
1 5 aaaaaaaa
2 5 bbbbbbbb
3 6 cccccccc
一个会员可以发布多条信息,我要的查询结果是
1 5 aaaaaaa
3 6 ccccccc
或者是 2 5 bbbbbbb
3 6 ccccccc
都行 也就是说 我想取到所有会员发布的一条信息。
我想过去重复的办法 但是只能是 行去重复 不能按会员的id去重复
请大家帮忙 谢谢
[解决办法]
SELECT a.* FROM TABNAME a INNER JOIN
(SELECT 会员ID, MAX(id) AS id
FROM TABNAME
GROUP BY 会员ID) b ON a.会员ID = b.会员ID AND a.ID = b.ID
[解决办法]
sql = "SELECT a.* FROM TABNAME a INNER JOIN (SELECT 会员ID, MAX(id) AS id "&_
"FROM TABNAME GROUP BY 会员ID) b ON a.会员ID = b.会员ID AND a.ID = b.ID "
rs.open sql,conn,1
[解决办法]
SELECT * from 供应表 as A where A.id in (select top 1 B.id from 供应表 as B where B.会员id=A.会员id)