mysql - Display return value as column name in sql -


i'm trying run query in mysql return products , it's specifications. managed make query follows:

select `brands`.`name`,`products`.`reference`,`specifications`.`name`,`specs-product`.`value`   `specs-product`   inner join `products` on `specs-product`.`product-id`=`products`.`product-id` inner join `specifications` on `specs-product`.`specification-id`=`specifications`.`specification-id`   inner join `brands` on `products`.`brand-id`=`brands`.`brand-id`    `specs-product`.`product-id` in (1,2,3,4,5,6,7,8)  ,  ( `specs-product`.`specification-id`='88' or  `specs-product`.`specification-id`='103' or  `specs-product`.`specification-id`='18' or  `specs-product`.`specification-id`='15' or  `specs-product`.`specification-id`='157' or  `specs-product`.`specification-id`='89' or  `specs-product`.`specification-id`='9' or  `specs-product`.`specification-id`='223' or  `specs-product`.`specification-id`='224' or  `specs-product`.`specification-id`='29' or  `specs-product`.`specification-id`='87' or  `specs-product`.`specification-id`='219' or  `specs-product`.`specification-id`='218' or  `specs-product`.`specification-id`='220' ); 

it returns values , works fine. i'm trying display values specifications of product shown in single row. in effect there 8 rows returned result.

how can achieve this?

try one:

select   b.name brand,   p.reference reference,   (     select value     `specs-product`     `specification_id` = 88       , `product_id` = p.`product_id`   ) weight,   (     select value     `specs-product`     `specification_id` = 103       , `product_id` = p.`product_id`   ) toneryield,   (     select value     `specs-product`     `specification_id` = 18       , `product_id` = p.`product_id`   ) stdpapercapacity,   (     select value     `specs-product`     `specification_id` = 15       , `product_id` = p.`product_id`   ) speed,   (     select value     `specs-product`     `specification_id` = 157       , `product_id` = p.`product_id`   ) resolution,   (     select value     `specs-product`     `specification_id` = 89       , `product_id` = p.`product_id`   ) powerreqs,   (     select value     `specs-product`     `specification_id` = 9       , `product_id` = p.`product_id`   ) maxmonthdutycycle,   (     select value     `specs-product`     `specification_id` = 223       , `product_id` = p.`product_id`   ) lowprice,   (     select value     `specs-product`     `specification_id` = 224       , `product_id` = p.`product_id`   ) highprice,   (     select value     `specs-product`     `specification_id` = 29       , `product_id` = p.`product_id`   ) documentfeeder,   (     select value     `specs-product`     `specification_id` = 87       , `product_id` = p.`product_id`   ) dimensions,   (     select value     `specs-product`     `specification_id` = 219       , `product_id` = p.`product_id`   ) colorimpressions,   (     select value     `specs-product`     `specification_id` = 218       , `product_id` = p.`product_id`   ) blackimpressions,   (     select value     `specs-product`     `specification_id` = 220       , `product_id` = p.`product_id`   ) blacktonerinsqrfeet products p inner join brands b on b.`brand_id` = p.`brand_id` 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -