PDA

View Full Version : New To Sql


stuman413
10-13-03, 19:09
I am new to sql and have a project that requires me to join multiple tables. Currently I am trying to join two tables that both have names and addresses of people. One table is of adults and the other is of children with supervising adults. I have been able to create a join of both of them, but, for instance, when an adult is listed as the supervising adult for a child, the adult list is almost doubled in size making the table an untrue reflection of what I am trying to achieve. Can anyone help me with this problem?

thanks

stu

Maroonotmoron
10-21-03, 12:41
Need more information on fields and what you are trying to join to. If you want a single list on names than you may want to list All children, All Adults and, All supervising Adults not in the adult list.

Maroonotmoron
10-21-03, 12:44
Need more information on fields and what you are trying to join to. If you want a single list on names than you may want to list All children, All Adults and, All supervising Adults not in the adult list.

Or you may only want all adults and All children.

What you want will determine your query/join

sundialsvcs
10-21-03, 13:03
Originally posted by stuman413
I am new to sql and have a project that requires me to join multiple tables. Currently I am trying to join two tables that both have names and addresses of people. One table is of adults and the other is of children with supervising adults. I have been able to create a join of both of them, but, for instance, when an adult is listed as the supervising adult for a child, the adult list is almost doubled in size making the table an untrue reflection of what I am trying to achieve. Can anyone help me with this problem?


If a parent has two children then a join will produce a {parent, child} row for each child; thus the parent's name will indeed be listed twice. Perhaps you should state what the result is that you want. Do you want "all parents, with their name and address?" In that case your query might involve the Child table but have no checkmarked fields (QBE grid) or would list only fields from the Parent table in the SELECT clause {listing the child table only in the JOIN clause}.

Also don't overlook the idea of running two queries in a row. Run one to get the base results... even with duplicated parents... then query that answer-table to select the parent-name, address, and so-on. Then run your report or what-have-you from that second result table.

"Anything that gets you what you want" will work just as well.