Solved

mysql query doubt

Posted on 2014-03-19
5
171 Views
Last Modified: 2014-03-19
Sql:
SELECT `vovariationid`, `voname`, group_concat(`vovalue`) FROM `isc_product_variation_options` group by vovariationid ,voname

Data;
vovariationid       voname       group_concat(`vovalue`)       
1       Cor       Preto+lilás,Prata+lilás
1       Tamanho       25,26,27,28,29,30,31,32
2       Cor       Preto,Marinho
2       Tamanho       25,26,27,28,29,30

Need output in the below format , can you please help me on the sql ?

Output

vovariationid       Cor       Tamanho      
1       Preto+lilás,Prata+lilás 25,26,27,28,29,30,31,32
2       Preto,Marinho 25,26,27,28,29,30

Thanks in advance
0
Comment
Question by:magento
  • 2
  • 2
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39939832
what about this:
SELECT `vovariationid`
 , group_concat(case when `voname` = 'Cor' then `vovalue` end) Cor
 , group_concat(case when `voname` = 'Tamanho' then `vovalue` end) Tamanho      
FROM `isc_product_variation_options` 
group by vovariationid 

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39939937
With questions like this it's sometimes helpful to post the CREATE TABLE statements so we can see exactly what we're working with.
0
 
LVL 5

Author Closing Comment

by:magento
ID: 39940316
Exactly what i am looking for , Thank you.
0
 
LVL 5

Author Comment

by:magento
ID: 39940321
Ray ,

I am sorry didnt see ur post , please find the create table statement

CREATE TABLE IF NOT EXISTS `isc_product_variation_options` (
  `voptionid` int(11) NOT NULL AUTO_INCREMENT,
  `vovariationid` int(11) NOT NULL DEFAULT '0',
  `voname` varchar(255) NOT NULL DEFAULT '',
  `vovalue` text,
  `vooptionsort` int(11) NOT NULL DEFAULT '0',
  `vovaluesort` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`voptionid`),
  KEY `i_product_variation_options_vovariationid` (`vovariationid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9471 ;

Thanks
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39940352
Thanks for posting that.  Glad you got a good answer, even if I didn't see the table in time!

Best regards, ~Ray
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now