有一条语句,联合查询的,表中的XH字段是唯一的,可是却查出来了3条一样的数据,后来同事帮忙看了下,才发现,原来是忘记加table1.id=table2.id了

SELECT hmd.xh as xh,hmd.lrdw as lrdw,hmd.czy as czy,hmd.larq as larq,hmd.yxq as yxq,hmd.wfxz as wfxz,hmd.hpzl as hpzl,hmd.hphm as hphm,hmd.bz as bz,hmd.fdjh as fdjh,hmd.clpp as clpp,hmd.cjh as cjh,hmd.jdcsyr as jdcsyr,hmd.cllx as cllx,hmd.csys as csys,hmd.tjbz as tjbz,hmd.fz as fz,hmd.ip as ip,hmd.bm as bm FROM kk.kkhmd hmd,kk.kkyh yh,kk.kkbmqx bmqx WHERE yh.id = 'heisetoufa'  and hmd.yxq = to_date('2008-04-20','YYYY-MM-DD HH24:MI:SS') and hmd.wfxz = '234234' and hmd.hpzl = '03' and hmd.hphm = '234234' and hmd.bz = 'D' and hmd.fdjh = '23423' and hmd.clpp = '23424' and hmd.cjh = '23423' and hmd.jdcsyr = '234234' and hmd.cllx = 'J11' and hmd.csys = 'CC' and hmd.tjbz = '234234' and hmd.lrdw = '北京市ZL发展公司' and bmqx.bm in ('研发部') and yh.id=bmqx.id



 

 

 

重点就是 yh.id=bmqx.id

黑色头发  http://heisetoufa.iteye.com

如果发现本文有误,欢迎批评指正