Solved

mysql query doubt

Posted on 2014-03-19
5
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

630 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