I pop into a problem recently, and Im sure its because of how I Join them.
this is my code:
on LP_Pending_Info.Service_order = LP_Part_Codes.Service_order
on LP_Pending_Info.Service_Order = LP_PS_Codes.Service_Order
on LP_Pending_Info.Service_Order = LP_Confirmation_Codes.Service_Order
order by LP_Pending_Info.Service_order, LP_Part_Codes.PartCode;
If your records were exactly the same the
distinct keyword would have solved it.
However in rows 2 and 3 which have the same
Part_Code if you check the
SO_NO you see it is different - that is why distinct won't work here - the rows are not identical.
I say you have some problem in one of the conditions in your
joins. The different data is in the
SO_NO column so check the raw data in the
LP_Confirmation_Codes table for that
select * from LP_Confirmation_Codes where Service_Order = 4182134076
I assume you are missing an
and with the value from the
LP_PS_Codes (but can't be sure without seeing those tables and data myself).
By this sentence If the service order have only one value it show the result correctly but when it have more than one Part code the problem begin. - probably you are missing and
and with the