在mysql中可以这样查询吗:
select A.*,B.* from A,B where A.c1=B.c1 orA.c1=B.c2 and A.c2=B.c1 or A.c2=B.c2;

解决方案 »

  1.   

    select A.*,B.* 
    from A,B 
    where (A.c1=B.c1 or A.c1=B.c2) 
    and (A.c2=B.c1 or A.c2=B.c2);注意 AND 和 OR 的运算优先顺序。加上括号。
      

  2.   


    SELECT vq.*,bicc.calling_number,bicc.called_number 
    FROM bicc20090601000000 bicc,vq20090601000000 vq 
    where (bicc.local_sdp_ip=vq.src_ip or bicc.local_sdp_ip=vq.dst_ip) 
    and (bicc.remote_sdp_ip=vq.dst_ip or bicc.remote_sdp_ip=vq.src_ip) 
    and (bicc.local_sdp_port=vq.src_port or bicc.local_sdp_port=vq.dst_port) 
    and (bicc.remote_sdp_port=vq.dst_port or bicc.remote_sdp_ip=vq.src_port) 
    and 1=1 limit 0,1;