Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mysql query doubt

Posted on 2014-03-19
5
Medium Priority
?
199 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 2000 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 111

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 111

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The viewer will learn how to count occurrences of each item in an array.
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…

715 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