现在有四个表分别是A,B,C,D表
由于查询条件涉及到D表,而A表跟B表是一对多关系,B跟C也是一对多关系,C跟D也是一对多关系,
主要查询数据是A表,一直关联到最后一个表,SQL如下:
select
        seller.id as id,
        seller.seller_name as seller,
        seller.contact as contact,
        seller.tel as tel,
        seller.email as email,
        seller.property as property,
        seller.address as address,
        seller.productCategory_id as productC,
        seller.start_date as start,
        seller.end_date as end 
    from
        qc_seller seller 
    left outer join
        qc_product_category productcat1_ 
            on seller.productCategory_id=productcat1_.id 
    left outer join
        qc_info infos 
            on seller.id=infos.seller_id 
    left outer join
        qc_cbd cbd 
            on infos.cbd_id=cbd.id 
    left outer join
        qc_district district 
            on cbd.district_id=district.id 
    where  后面跟条件现在问题是由于是要查A表的数据,但是条件在其它几个关联的表中,每次查的时候关联第第二个表的时候就会出现只要第二个表中有的数据就会有重复的数据。
他们的关联关系设计是又是必须的,如何去除查询出来的重复数据?