Problem solve Get help with specific problems with your technologies, process and projects.

Query of a view returning repeating records

I'm trying to create a view based on three tables: a master table and two child tables. The two child tables are...

independent, but they are related to the master table through a foreign key, When I query the view, Oracle gives the results repeating for each table the number of records from the other table.

An example would have been nice to better diagnose the problem....

Your problem doesn't have to do with the view, but the underlying query of the view. In particular, make sure that you pay attention to your WHERE clause, which specifies how the join is to take place. Since you are joining three tables, you need to specify two join conditions in the WHERE clause.

For instance, suppose I have three tables, A,B, and C. To further match your example, assume that table A is the "master" table and tables B and C are the "child" tables. My WHERE clause might look something like the following:

WHERE A.b_id = B.id
  AND A.c_id = C.id
  AND (add other limiting conditions here)
Make sure that your WHERE clause is correct.

For More Information

This was last published in February 2003

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.