SQL group by 用法
有这样一个表
id 发送者ID 接受者ID 内容
1 A_ID B_ID XXXX
2 A_ID B_ID YYYY
3 A_ID B_ID ZZZZ
4 C_ID A_ID OOO
5 B_ID A_ID PPPPP
6 B_ID A_ID QQ
7 A_ID D_ID MMMM
8 D_ID A_ID NNNNN
去除重复,将与A_ID有过关系的 B_ID , C_ID ,D_ID的ID查出来
有这样一个表
id 发送者ID 接受者ID 内容
1 A_ID B_ID XXXX
2 A_ID B_ID YYYY
3 A_ID B_ID ZZZZ
4 C_ID A_ID OOO
5 B_ID A_ID PPPPP
6 B_ID A_ID QQ
7 A_ID D_ID MMMM
8 D_ID A_ID NNNNN
去除重复,将与A_ID有过关系的 B_ID , C_ID ,D_ID的ID查出来
解决方案 »
- 菜鸟求解!android模拟器启动问题
- 自定义Adapter中getView调用次数的问题
- 求安卓开发工具 与教学视频
- httpCliet与httpURLConnection 主要区别及使用场合
- 看到北大的那个“颐和园路5号"有个想法
- 开发android应用的总体思路是什么样的?
- 关于如同网易,人人客户端的新闻保存问题
- 关于Android使用HttpPos方式带参数访问Asp.net网页问题
- android httpProxy 混淆后无法捕获 自定义异常
- android中px,dp,dip和sp有什么不同?
- android -soap 问题~~~~~~~~
- android内核下载问题 newline错误
select dstinct 发送者ID from table1 where 接收者ID = 'A_ID'
union
select distinct 接收者ID from table1 where 发送者ID ='A_ID'
或
select distinct case 发送者ID ='A_ID' then 接收者ID else 发送者ID end from table1 where
接收者ID ='A_ID' or 发送者ID = 'A_ID' 可以不用group by 的
但是在下面写了while (cursor.moveToNext()) {
Message message= new Message ();
message.id = cursor.getString(cursor
.getColumnIndex("id"));
message.senderId = cursor.getString(cursor
.getColumnIndex("senderId"));
message.recipientId = cursor.getString(cursor
.getColumnIndex("receId"));
list.add(message);
}报错 ,需求是要得到message对象及里面的参数数据,只用select distinct 是不行的,该怎么改呢?需要用select * from ?