avoid duplicates in multiple joins

LISA GEORGE used Ask the Experts™
Hi, i have query where i joined 4 tables and i am getting 3 records which is correct
but as soon as i joined 5th table records getting duplicated. i am getting 9 records now
can someone help me how can we eliminate duplicate records in multiple joins
all joins i am using is inner join
i am running query in oracle db but this should be same in sql db as well.
i referred some forums but that didn;t helped me much
any help is much appreciated.
thank you
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Distinguished Expert 2018

Check the join columns for the 5th table.  It is causing 3 rows to be returned which is causing the 3 original rows to combine to 9.

Without the query, sample data and expected results, we don't have much to go on.
ste5anSenior Developer

Well, what is the real problem?

1) If there are really duplicates, then the data model is not correct and it's missing further normalization and constraints.
2) If there are really duplicates and the data model is correct, then you're missing a further WHERE or JOIN condition or another JOIN to remove them.
3) There are no duplicates, you've just missed to include the columns into the column list of the SELECT, which makes the row unique.

Keep in mind that a JOIN means that the rows of left side of the JOIN is multiplied by the rows of the right side of the JOIN. So "row inflation" of the left side is normal.
Mark GeerlingsDatabase Administrator

it sounds like your join to the fifth table is incomplete.  Either that join needs to be based on two columns, not just one, or there is some other column in that fifth table that you should add a "where" clause condition for to filter out the extra rows from this table that you don't want to be excluded.  Or, you could add a "group by" clause for that fifth table.
HI all,

thank you for your suggestions. i have find out solution by adding some other busineess condition so now it's getting desired result.

thank you for your time once again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial