2016-04-08 9 views
-3

私はtable1、table2、table3と呼ばれる3つのテーブルを持っています。各テーブルは主キーを含んでいます。すべての3つのテーブルに共通の製品テーブル。 3つのテーブルのすべての主キーが含まれています。いいえ、入れ子になった配列として商品の詳細を表示したいのですがどうすればいいですか?mysqlでjoinを使ってすべての製品を表示する方法

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

..私はこれがあなたのために働くことを願って、[複数のテーブル* FROM \ SELECTの可能な複製を複数の左では、次のSQLクエリ合流を使用しています。 MySQL](http://stackoverflow.com/questions/12890071/select-from-multiple-tables-mysql) – Tom

+0

あなたはあなたの答えを詳しく述べることができます –

+0

私はそれが可能な複製は、あなたが探している答えが含まれていると言った質問。 – Tom

答えて

0

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 
関連する問題