当前位置: 代码迷 >> Android >> android里面如何在一张表中查询出2条字段数据交叉
  详细解决方案

android里面如何在一张表中查询出2条字段数据交叉

热度:37   发布时间:2016-04-28 05:19:30.0
android里面怎么在一张表中查询出2条字段数据交叉
例如A条记录的id为1,otherID为2
B记录的id为2,otherID为1,
怎么同时将这2条记录查询出来,就这2个字段的数据的关联的
------解决方案--------------------
引用:
这个groups提示没这一行

我这没问题啊。

还有个思路:
select * from tb t1 where t1.id<t1.otherID  and  exists(select 1 from tb t2 where t1.id=t2.otherID and t1.otherID=t2.id)
查出来的都是id<otherid的那一条,然后java代码中循环遍历的时候add两条就可以
add(id,otherid)
add(otherid,id)
  相关解决方案