Php 如何在mysql中使用join显示所有产品
我有三个表,分别称为table1、table2和table3,每个表都包含一个主键。三个表共用的产品表。其中包含三个表的所有主键。否我想以嵌套数组的形式显示产品详细信息我如何才能做到这一点Php 如何在mysql中使用join显示所有产品,php,mysql,Php,Mysql,我有三个表,分别称为table1、table2和table3,每个表都包含一个主键。三个表共用的产品表。其中包含三个表的所有主键。否我想以嵌套数组的形式显示产品详细信息我如何才能做到这一点 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 li
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 }
将以下sql查询与多个左连接一起使用,我希望这对您有用
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
你能详细说明你的答案吗?我说的问题可能是你要找的答案的副本。你应该花更多的精力把你自己的问题格式化。阅读结构并不容易。是的,很可能已经有人回答了,这意味着你想让我们来搜索你