MySQL Forums
Forum List  »  InnoDB

INSERT AfTER LEFT JOIN creates duplicate records
Posted by: Brad Liu
Date: September 19, 2016 03:49PM

Below is the stored procedure running at work hours every day. The purpose is to add new and update records from SBT to so_detail.

INSERT INTO so_detail
(so_num, cust_num, part_num, descrip, disc, cost, price, qtyord, qtyshp, extprice, ord_date, req_date, dealer_type, part_cls, location, sostat, discls, wh_id)
SELECT s.sono, s.custno, s.item, s.descrip, s.disc, s.cost, s.price, s.qtyord, s.qtyshp, s.extprice, CONCAT(s.ordate, ' ', time(now())), CONCAT(s.rqdate, ' ', time(now())),
s.terr, s.class, s.seq, s.sostat, s.disclass, whID
LEFT JOIN so_detail d ON s.sono = d.so_num AND s.item = d.part_num
WHERE d.so_num IS NULL;

Almost every one month, there is duplicated record (exactly the same for two lines of records ) in so_detail created.
Has no clue where these duplicates come from.
There is no place to insert screenshot? :)

Thank You!

Options: ReplyQuote

Written By
INSERT AfTER LEFT JOIN creates duplicate records
September 19, 2016 03:49PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.