2016-04-08 3 views
-3

Ich habe drei Tabellen namens table1, table2 und table3 jede Tabelle enthält einen Primärschlüssel. Produkttabelle für alle drei Tabellen. die den gesamten Primärschlüssel der drei Tabellen enthalten. nein ich möchte die Produktdetails als verschachteltes Array anzeigen, wie kann ich das tun?Wie alle Produkte mit Join in mysql anzuzeigen

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

Mögliche Duplikat [SELECT \ * aus mehreren Tabellen. MySQL] (http://stackoverflow.com/questions/12890071/select-from-multiple-tables-mysql) – Tom

+0

können Sie bitte erarbeiten Sie Ihre Antwort –

+0

Die Frage, die ich sagte, es ist ein mögliches Duplikat enthält die Antwort, die Sie suchen . – Tom

Antwort

0

die folgende SQL-Abfrage mit mehreren linken verbindet, ich hoffe, dass dies .. für Sie arbeiten

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