Jump to content

Joining 3 tables to get results in DW


Recommended Posts

Hi,

I am setting up a member website/buyer's guide. I have 3 tables. My tables are Member - which holds the member details such as MemberID company name, phone, web, etc. Categories - which holds the CategoryID and CategoryName. And MemberCategory which holds the MemberCategoryID, f_MemberID (foreign key to members table) and f_CategoryID (foreign key to Category table).

 

I have set up a jump menu at http://www.aafw.org/Association/AssocBuyersGuide2.php to pull the Category Names from the Categories table. Now I just need it to be able to when a user selects a category from that list to go to a page that lists all of the companies who belong to that category.

 

Right now I'm using this code:

 

SELECT Member.MemberID, Member.CompanyName, Member.Phone, Member.TollFree, Member.Fax, Member.Address, Member.City, Member.`State`, Member.Zip, Member.Website, Member.Descriptions, Member.Email, MemberCategory.MemberCategoryID, MemberCategory.f_MemberID, MemberCategory.f_CategoryID, Categories.CategoryID, Categories.CategoryName

FROM Member, MemberCategory, Categories

WHERE Categories.CategoryID = MemberCategory.f_CategoryID AND MemberCategory.f_MemberID = Member.MemberID

ORDER BY Member.CompanyName ASC

 

What happens is that it lists all members that belong to a category, any category, not just the category selected by the user. I'm guessing that I need to use a LEFT JOIN but I'm not really familiar with all of that.

 

Any help?

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.