We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,470 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

SELECT and display records from three linked Tables in MySQL

I have three table that are linked like this. Each content is linked to a category and each category is linked to a section. Like this

sections_table
-section_id
-section_name

categories_table
-category_id
-section_id
-category_name

contents_table
-content_id
-category_id
-content_title
-content_description

I want to write a query to display only content from a particular section and I am having difficulty, can someone help me with writing my query? Thank you

3
Contributors
2
Replies
22 Hours
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
patrick1981
Newbie Poster
19 posts since Feb 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
SELECT `contents_table.content_id`, `contents_table.content_title`, `contents_table.content_description`
From `contents_table`, `categories_table`, `selection_table`
WHERE `selection_table.selection_id` = selectedID
AND `selection_table.selection_id` = `categories_table.selection_id`
AND `categories_table.category_id` = `contents_table.category_id`

I think this should do it

t_thakar
Newbie Poster
10 posts since Mar 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
rajeevphp2011
Light Poster
26 posts since Nov 2011
Reputation Points: 7
Solved Threads: 6
Skill Endorsements: 1
Question Answered as of 1 Year Ago by rajeevphp2011 and t_thakar

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0855 seconds using 2.7MB