我尝试在导出为 csv 格式之前生成数据,但我未能获得正确的数据。
Table : products
products_id | products_image
2 | a.jpg
1786 | b.jpg
Table : product_description
products_id | products_description | language_id
2 | BM description | 6
1786 | BM description | 6
1786 | CN description | 4
1786 | EN description | 1
我试图得到这样的输出:
products_id | products_image | p_description_6 | p_description_4 | p_description_1 |
2 | a.jpg | BM description | | |
1786 | b.jpg | BM description | CN description | EN description |
我当前的查询如下,但此查询未能在同一行中生成 product_description:
$select = "SELECT p.*, pd.* FROM products p LEFT JOIN product_description pd on p.products_id=pd.products_id group by p.products_id";