-3

I have three tables called table1, table2 and table3 each table contains a primary key. products table common to all the three tables. which contain all the primary key of the three tables. no i want to display the products details as a nested array how can i do that?

table1 contains:
name
id

table2 contains:
name
id

table3 contains:
name
id
products table
id
name
description
table1_id
table2_id
table3_id

my output like 
table1 
{
name 
  { products.name, products.description },
  { products.name, products.description }
}
  table2
   name { products.name, products.description },
   { products.name, products.description }
  }
   table3
   {
   name {products.name, products.description},
  { products.name, products.description }
  • 2
    Possible duplicate of [SELECT \* FROM multiple tables. MySQL](http://stackoverflow.com/questions/12890071/select-from-multiple-tables-mysql) – Tom Apr 08 '16 at 09:51
  • can you please elaborate your answer – Matthew Vijay Apr 08 '16 at 09:51
  • The question I said it is a possible duplicate of contains the answer you are looking for. – Tom Apr 08 '16 at 09:53
  • You should have put more effort into formatting your own question. It's not really easy to read the structure. And yes, most likely it was already answered, which means you want us to do the search for you – ᴍᴇʜᴏᴠ Apr 08 '16 at 10:50

1 Answers1

0

use the following sql query with multiple left joins, i hope this will work for you..

select * from  products
left join table1  
on table1.id = products.table1_id
left join table2  
on table2.id = products.table2_id
left join table1  
on table3.id = products.table3_id
Manjeet Barnala
  • 2,975
  • 1
  • 10
  • 20