php - SQL JOIN Statement - Generate data before export -


i try generate data before export csv format im failed right data.

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 

i try output :

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  | 

my current query below query failed generate product_description in same row:

$select = "select p.*, pd.* products p left join product_description pd on p.products_id=pd.products_id group p.products_id"; 

try like,

select     p.products_id,     p.products_image,     max(case when language_id = 6 products_description  end) p_description_6,     max(case when language_id = 4 products_description  end) p_description_4,     max(case when language_id = 1 products_description  end) p_description_1       products p   inner join      product_description d on p.products_id = d.products_id  group      p.products_id,     p.products_image 

sql fiddle


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -