Solved

mysql query doubt

Posted on 2014-03-19
5
182 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 143

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 110

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 110

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

713 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