Solved

mysql query doubt

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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 look for a specific file type in a local or remote server directory using PHP.

896 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

11 Experts available now in Live!

Get 1:1 Help Now