List:General Discussion« Previous MessageNext Message »
From:Schalk Neethling Date:May 2 2005 11:01am
Subject:Re: joining six tables by mutual column
View as plain text  
Mathias/Everyone on the list

I am running the following query against the database:

SELECT demographic.demographic_no, demographic.first_name, 
demographic.last_name, demographic.chart_no,, 
demographic.year_of_birth, demographic.month_of_birth, 
demographic.date_of_birth, demographic.family_doctor, 
demographic.roster_status, demographic.patient_status, 
FROM allergies, demographic, drugs, echart, dxresearch, ichppccode WHERE 
demographic.demographic_no = '1' AND demographic.last_name LIKE 'TES' 
AND allergies.demographic_no = demographic.demographic_no AND 
demographic.demographic_no = drugs.demographic_no AND 
drugs.demographic_no = dxresearch.demographic_no AND 
dxresearch.demographic_no = echart.demographicNo AND 
allergies.demographic_no = echart.demographicNo AND 
dxresearch.dxresearch_code = ichppccode.ichppccode

Is the string at the end from, 'AND allergies.demographic_no = 
demographic.demographic_no...', the correct way to create the JOIN I 
require by demographic_no on five of the tables and then a JOIN of the 
dxresearch and ichppccode tables by dxresearch_code and ichppccode 
respectively? Any help or pointers would be much appreciated. Thank you!

mathias fatene wrote:

>Select * from table1 T1, table2 T2, table3 T3, table4 T4, table5 T5,
>table6 T6 
>Where T1.col=T2.col
> and T2.col=T3.col
> and T3.col=T4.col
> and T4.col=T5.col
> and T5.col=T6.col
> and T1.col=T6.col
>[and col='val']
>Doesn't this work ? Have you an example ?
>Best Regards
>Mathias FATENE
>Hope that helps
>*This not an official mysql support answer
>-----Original Message-----
>From: Schalk Neethling [mailto:schalk@stripped] 
>Sent: lundi 25 avril 2005 00:52
>To: mysql@stripped
>Subject: joining six tables by mutual column
>Greetings everyone.
>Hope someone can give me some pointers here. I have six tables in the 
>database and I need to JOIN them on a row that appears in all of the 
>tables. How do I do this? I have so far done the normal 'cross-join' 
>saying SELECT * FROM table1, table2, table3, table4, table5, table6 
>WHERE something = something;
>I have also added STRAIGHT_JOIN to force the order but, how do I JOIN 
>six tables to/by one column? I have done some google searches as well as
>looked at MySQL 2nd edition by Paul DuBois, sorry if I missed something 
>here Paul, and so far I have not found an answer. Any help or pointers 
>will be appreciated. Thank you.

Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Tel: +27125468436
Fax: +27125468436
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@stripped

We support OpenSource
Get Firefox!- The browser reloaded -
This message contains information that is considered to be sensitive or confidential and
may not be forwarded or disclosed to any other party without the permission of the sender.
If you received this message in error, please notify me immediately so that I can correct
and delete the original email. Thank you.

joining six tables by mutual columnSchalk Neethling25 Apr
  • Re: joining six tables by mutual columnRichard Lynch25 Apr
  • RE: joining six tables by mutual columnmathias fatene25 Apr
    • Re: joining six tables by mutual columnSchalk Neethling2 May
      • Re: joining six tables by mutual columnPeter Brawley2 May
      • Re: joining six tables by mutual columnMichael Stassen2 May
  • Re: joining six tables by mutual columnNick Pasich25 Apr