Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clarification on my Join question

Status
Not open for further replies.

EveatEden

Programmer
Jul 25, 2000
3
US
Basically Table A contains a list of insurance policies while Table B contains a list of accidents.  Some 10 or so fields are the same in Table A as in Table B.  Those fields are used to find matching records and then those records are joined and placed in Table C.  The problem is that Table B may have multiple accidents listed for the same policy number.  I need Table C to have only one record per policy number.  I was just talking to someone else who said if I used distinct in front of the field for the policy number instead of for the Select statement itself that is should work.  Does that sound right to you guys?  If not do you have another solution?
 
Don't *think* so.<br><br>My understanding is that you have to say<br><br>Select Distinct &lt;field_list<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Myabe you need to question why you are doing this. <br><br>Why are you creating a table from data in two other tables? If you require information you should just join the existing two, not create a third. This can lead to data redundancy and integrity issues.<br><br>Also, why are you trying to combine a one to many relationship into a one to one relationship?<br><br>If you have valid reason for doing this, then I'm sure it could be done. <br><br>I'm&nbsp;&nbsp;not critising your design, I'm only saying that maybe you should review it.<br><br> <p>Cal<br><a href=mailto: > </a><br><a href= > </a><br>
 
If you select distinct then you do no not control which records you select. <br>You may for instance only require the latest accident in which case you need to create a where clause to select on the latest date only. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top