select pmbh as 条码号,pm AS 品名,kh as 款号,zsh1 as 证书号,dw as 单位,dqkc as 数量,weight as 重量,weight1 as 件重,gg AS 规格,szj as 市值价,xsj as 销售价,stoneweight as 主石重,ls as 粒数,B.ys as 颜色,zd as 净度,cg as 切工,xz as 形状,lb as 类别,pp as 商品类型,A.djh as 单据号,A.gysbh as 供应商 from (select pmbh as pmbh1,pm,kh,zsh1,dw,sl,weight,weight1,gg,szj,xsj,lb,pp,t_lcd.djh,gysbh,rhch,jsr,rcrq from t_lcd inner join t_lclsz on t_lcd.djh=t_lclsz.djh) A left join (select pmbh,dqkc,ckbh,bar,stoneweight,ls,ys,zd,CG,xz from t_kcb left join (select * from t_stone where sfzs='主石') X on X.bar=t_kcb.pmbh) B on A.pmbh1=B.pmbh where dqkc=1 and ckbh='南京新百' and A.pm like 'PT950项链%' order by pmbh asc为什么数据库中dqkc=0的也可以查出来?

解决方案 »

  1.   

    Try:
    select pmbh as 条码号,pm AS 品名,kh as 款号,zsh1 as 证书号,dw as 单位,dqkc as 数量,weight as 重量,weight1 as 件重,gg AS 规格,szj as 市值价,xsj as 销售价,stoneweight as 主石重,ls as 粒数,B.ys as 颜色,zd as 净度,cg as 切工,xz as 形状,lb as 类别,pp as 商品类型,A.djh as 单据号,A.gysbh as 供应商 from (select pmbh as pmbh1,pm,kh,zsh1,dw,sl,weight,weight1,gg,szj,xsj,lb,pp,t_lcd.djh,gysbh,rhch,jsr,rcrq from t_lcd inner join t_lclsz on t_lcd.djh=t_lclsz.djh) A left join (select pmbh,dqkc,ckbh,bar,stoneweight,ls,ys,zd,CG,xz from t_kcb left join (select * from t_stone where sfzs='主石') X on X.bar=t_kcb.pmbh) B on A.pmbh1=B.pmbh and dqkc=1 where ckbh='南京新百' and A.pm like 'PT950项链%' order by pmbh asc