List:General Discussion« Previous MessageNext Message »
From:Amy Thornton Date:February 14 2006 5:04pm
Subject:joining 3 tables
View as plain text  
I am trying to join 3 tables together.

Table A has 3 fields: sub_id, subject, id
Table B has 3 fields: ref_cat_id, sub_id, ref_cat
Table C has 7 fields: uid, ref_cat_id, etc.

I am trying to join Table A and B over sub_id and join B and C over ref_cat_id
while pulling in the value of sub_id and ref_cat_id from a php program

I tried doing it this way:

select reference.uid from reference, subject_name, ref_cat where 
subject_name.sub_id = '45' and ref_cat.ref_cat_id = '3' and 
ref_cat.ref_cat_id = reference.ref_cat_id and subject_name.sub_id = 
ref_cat.sub_id

with the '45' and '3' being the values coming from my variables in 
PHP.  We only have MySql 4.0 so I can't use a subquery.

If anyone has any suggestions I would be very thankful.  Please also 
let me know if I need to provide more information about the problem.

Thank you for your time and help.

Amy Thornton, Electronic Services Specialist
Information Services, Cook Library
The University of Southern Mississippi
118 College Drive #5053
Hattiesburg, MS 39406-0001
Phone: (601) 266-6668
Fax: (601) 266-6857
E-mail: amy.thornton@stripped
http://www.lib.usm.edu/ 


Thread
joining 3 tablesAmy Thornton14 Feb
  • Re: joining 3 tablesThomas Spahni14 Feb
  • Re: joining 3 tablesPeter Brawley14 Feb