Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:24:27+00:00 2026-06-15T03:24:27+00:00

a rookie MYSQL user …. I have a simple MySQL query that returns values,

  • 0

a rookie MYSQL user …. I have a simple MySQL query that returns values, and uses the GROUP_CONCAT function:

SELECT Productid, Name, GROUP_CONCAT(value)
FROM search_export 
Group By Productid, Name;

Productid   Name                     GROUP_CONCAT(value)
666056542   Brand Name           Netgear
1054677552  Ethernet Technology  Gigabit Ethernet
665655662   Form Factor          Wall Mountable,Desktop
56565765    Media Type Supported     Twisted Pair

However, I need to transpose the query so it returns ‘Name’ as seperate columns, not a row. Is this possible at all with MySQL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:24:28+00:00Added an answer on June 15, 2026 at 3:24 am

    You need to perform a PIVOT operation, which is not supported natively in MySQL (unlike some other RDBMS).

    The closest you can get is to construct SQL along the following lines:

    SELECT   ProductId,
             GROUP_CONCAT(IF(Name='Brand Name'          ,value,NULL))
               AS `Brand Name`,
             GROUP_CONCAT(IF(Name='Ethernet Technology' ,value,NULL))
               AS `Ethernet Technology`,
             GROUP_CONCAT(IF(Name='Form Factor'         ,value,NULL))
               AS `Form Factor`,
             GROUP_CONCAT(IF(Name='Media Type Supported',value,NULL))
               AS `Media Type Supported`
    FROM     search_export
    GROUP BY ProductId
    

    If the possible Name values are dynamic, you could generate such SQL in a higher level language from the results of:

    SELECT DISTINCT Name FROM search_export
    

    Indeed, one could even use SQL itself:

    SELECT CONCAT('
             SELECT   ProductId, ',
           GROUP_CONCAT('
                      GROUP_CONCAT(IF(Name=',QUOTE(Name),',value,NULL))
                        AS `',REPLACE(Name,'`','``'),'`'
           ), '
             FROM     search_export
             GROUP BY ProductId
           ')
    INTO @sql
    FROM (
      SELECT DISTINCT Name FROM search_export
    ) t;
    
    PREPARE stmt FROM @sql;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
    

    Note that if there are a lot of different Name values, you may need to increase group_concat_max_len from its default of 1KiB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I first have to say that I really am a rookie in caching, so
This is probably a rookie question but; Let's say I have an ActionResult that
I'm a rookie VIM user. My problem is that VIM doesn't let me type
Using MySQL Administrator GUI tool I have exported some data tables retrieved from an
I have this classifieds website, and I have about 7 tables in MySql where
Quick rookie question please. Suppose I have a javsacript object like so: var meh=[[cars,27],
I'm a Java rookie and I was wondering, if I have the following typical
I am a rookie to android. I am thinking of implementing a simple calculator
PHP mysql database I have created a follow on question to this one here
This may be a rookie question but if I have created a suite of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.