Inner JOIN data duplication problem

Source: Internet
Author: User

When querying for data. It's strange to write a piece of SQL. No duplicate data occurs when you query data from the first 5 tables

There is a lot of duplicate data until the sixth table is associated (t_im_inventorybalance ). For a time it was depressing. Then consult the implementation personnel to know.

The original t_im_inventorybalance itself has multiple duplicate data, which means that when Material.fid = Ib.fmaterialid Association

It's a one-to-many relationship. Multiple conditions need to be set to avoid duplication.

Select Material.fid from T_im_stocktransferbill STB
INNER JOIN T_im_stocktransferbillentry stbe on stb.fid= stbe.fparentid
Inner JOIN t_bd_material material on material.fid = Stbe.fmaterialid
INNER JOIN t_bd_materialcompanyinfo mci on material.fid = MCI. Fmaterialid
INNER JOIN T_db_warehouse WAREHOUSE on STBE. Fissuewarehouseid = Warehouse.fid
INNER JOIN t_im_inventorybalance ib on material.fid = Ib.fmaterialid

 and ib. Fwarehouseid = Warehouse.fid and ..... The
 inner join T_im_storestate storestate on ib. Fstorestatusid = Storestate.fid
 inner join T_org_storage Storage on ib. Fstorageorgunitid = Storage.fid
 and fbizdate >= (select Fbegindate from t_bd_period where fnumber = ' 200910 ') Br> and fbizdate <= (select Fenddate from t_bd_period where fnumber = ' 200910 ')
 and warehouse.fnumber = ' K One '
 and STB. Fbasestatus = 7
 and ib. Fyear = 2009 and ib. Fperiod = Ten
 and STB. Fissuestorageorgunitid = ' 4ueezzgdsyuvfad/hlhijsznrtq= '
 and STB. Freceiptstorageorgunitid
 in (' ewbcbd/zq1+ebrrzduxf3cznrtq= ', ' acgiadkit7cs4dp40u7ktcznrtq= ',
      ' nxnw4ggnrh+axz/cmemfpcznrtq= ', ' 8vjd+kzurluqlkf2ysz3b8znrtq= ',
     ' 7b2aymbeskghpqv8xiks3cznrtq= ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.