仅对mysql有效,不考虑对其它数据库的兼容性
连接数据库
选择数据库
写查询语句:select 字段1,字段2... from 表名 where (AID=1  and BID=2)  or (AID=2 and BID=1)
执行查询语句。。