dbTalk Databases Forums  

simple query

comp.databases.ms-access comp.databases.ms-access


Discuss simple query in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sergiogroups@gmail.com
 
Posts: n/a

Default simple query - 09-12-2006 , 02:55 PM






If It have a table T_Contacts:

Name Gender FamilyID
John M 1
Paul M 2
Anna F 1
Kate F 2

And want to create a table T_Couples:

Husband Wife
John Anna
Paul Kate

which is the query to do that?


Reply With Quote
  #2  
Old   
pietlinden@hotmail.com
 
Posts: n/a

Default Re: simple query - 09-12-2006 , 03:44 PM







sergiogroups (AT) gmail (DOT) com wrote:
Quote:
If It have a table T_Contacts:

Name Gender FamilyID
John M 1
Paul M 2
Anna F 1
Kate F 2

And want to create a table T_Couples:

Husband Wife
John Anna
Paul Kate

which is the query to do that?
this should get you started .

SELECT Man.FamilyID, Man.FName As Husband, Wife.FName As Wife
FROM tblPeopl AS Man INNER JOIN tblPeopl AS Wife ON Man.FamilyID =
Wife.FamilyID
WHERE (((Man.Gender)="M") AND ((Wife.Gender)="F"));

i'm splitting out Man and Wife as two datasets in the same table, and
then joining the resulting sets of FamilyID. the where clause just
puts the men in one group and the women in another, so that I can join
on FamilyID.

Then just turn this into a maketable query and you're good to go.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.