Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:49:41+00:00 2026-06-11T06:49:41+00:00

How to SELECT 3 table in one query and show all product with price?

  • 0

How to SELECT 3 table in one query and show all product with price?

Below is my database structure(MySql) :

categories

+-------------+------------+
 category_id  | parent_id  |
+-------------+------------+
  1           |      0     
  2           |      1
  3           |      1
  4           |      1
  5           |      2
  6           |      3

products_to_categories

+-------------+------------+
 product_id   | category_id|
+-------------+------------+
  54          |      0     
  55          |      2
  56          |      2
  57          |      2
  58          |      3
  59          |      3
  60          |      4

products

+-------------+------------+
 product_id   |    price   |
+-------------+------------+
  54          |      10.50     
  55          |      11.20
  56          |      1.00
  57          |      22.20
  58          |      32.0
  59          |      32.0
  60          |      22.0

Below is my condition ;

1. table categories : parent_id = '1'  
(result : 2,3,4)

2. table products_to_categories : category_id = result categories(result : 2,3,4) 
(result : 55,56,57,58,59,60)

3. table products : inner join or left join table product to display price where product_id = result products_to_categories(result : 55,56,57,58,59,60)

Final Output

  55 - 11.20
  56 - 1.00
  57 - 22.20
  58 - 32.0
  59 - 32.0
  60 - 22.0

Before i post this question here is my previous query(im stuck how to proceed to condition 2)

$sql_all = mysql_query("SELECT cat.parent_id,cat.category_id FROM categories cat WHERE cat.parent_id='1' ");
while($row = mysql_fetch_array($sql_all)) {
echo $row['categories_id'].'<br/>'; 
}

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:49:43+00:00Added an answer on June 11, 2026 at 6:49 am

    Try this,

    SELECT  c.*
    FROM    categories a
            INNER JOIN products_to_categories b
                ON a.category_id = b.category_id
            INNER JOIN products c
                ON b.product_id = c.product_id
    WHERE  a.parent_id = 1
    

    This will display all records from products table having parent_id = 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a question regarding a SQL-select-query: The table contains several columns, one of
I'd like to select all rows from one table which match one or more
So I need to select distinct values from one table, but join all the
I am running this query which selects a few fields from one table and
I need to select multiple table and one of it is transposed, my table
I have a stored proc, SP1, which executes and does select on one table.
I need to select data from one table and insert it into another table.
I am trying to select rows from a table where one of the (NVARCHAR)
I'm trying to select most recent date from one table (invoice) to a customer
Well, I was trying to select rows from one table if there are no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.