mysql - SQL Query Interrogation Issue -


this query:

select f.fieldid,fd.fieldname, p.productid,pd.productname, p.price,p.stoc, p.isactive,textvalue products_products p left outer join products_products_details pd on pd.productid = p.productid left outer join fld_chosenvalues f on f.productid = p.productid inner join fld_fields_details fd on f.fieldid = fd.fieldid  pd.locale = "ro-ro" , fd.locale = "ro-ro" 

in image below , can see result of query : enter image description here

the problem want put "volum", "tip inchidere", "amabalare paiet", "ambalare bax" column , assign value "212ml"... can see in image below want :

enter image description here

i apologize images, didnt know other ways explain that. thx

this query pivot, not working :

select f.fieldid,fd.fieldname, p.productid,pd.productname, p.price,p.stoc, p.isactive,textvalue products_products p left outer join products_products_details pd on pd.productid = p.productid left outer join fld_chosenvalues f on f.productid = p.productid inner join fld_fields_details fd on f.fieldid = fd.fieldid pivot (     [f.fieldname] in (['volum'], ['tip inchidere'], ['amabalare palet'], ['ambalare bax']) ) pvt;  pd.locale = "ro-ro" , fd.locale = "ro-ro" 

maybe this:

select      p.productid,     pd.productname,     sum(p.price) price,     sum(p.stoc) stoc,     p.isactive,     max(case when fd.fieldname='volum' textvalue else null end) volum,     max(case when fd.fieldname='tip inchidere' textvalue else null end) tipinchidere,       max(case when fd.fieldname='amabalare paiet' textvalue else null end) amabalarepaiet,     max(case when fd.fieldname='ambalare bax' textvalue else null end) ambalarebax      products_products p     left join products_products_details pd         on pd.productid = p.productid     left join fld_chosenvalues f         on f.productid = p.productid     inner join fld_fields_details fd         on f.fieldid = fd.fieldid       pd.locale = 'ro-ro'      , fd.locale = 'ro-ro' group     p.productid,     pd.productname,     p.isactive 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -