Okay
  Public Ticket #2866068
Convert collumns intos rows
Closed

Comments

  • Warzone_Loadout started the conversation

    Hello, 

    I am creating a table using sql, but i would like to invert the Collumn and the Rows.

    See in attachments i have my table displayed exactly like in the source database. 

    I would like to have this data into collumns, with Type as collumn header and each Attribute as row headers. 

    Do you know how i could do that?

    Thank you so much in advance!

    Sincerely, 

    Alex


    PS: Here is my current SQL query: 

    SELECT Weapons.`Type`,
           Weapons.`Muzzle`,
           Weapons.`Barrel`,
           Weapons.`Laser`,
           Weapons.`Optic`,
           Weapons.`Stock`,
           Weapons.`Underbarrel`,
           Weapons.`Ammunition`,
           Weapons.`RearGrip`,
           Weapons.`Perk`
    FROM Weapons
    WHERE 1=1 
       AND Weapons.`Weapon` = 'C58'
    GROUP BY Weapons.`Type`


  • [deleted] replied

    Hi Alex

    Thank you for reaching out to us.

    I am sorry to disappoint you, but unfortunately, something like this is not possible with the plugin's built-in features.

    You would need to create a Pivot table in the database; then prepare a MySQL view (a stored query), which will return the data from that Pivot table, call it e.g. “view1” and then build a wpDataTable based on a simple query like “SELECT * FROM view1″.


  • Warzone_Loadout replied

    Ok thank you very much for your help!

    i will try to do this but i think it's out of my range of skills :D

    Have a nice day!

  •  1,708
    Miloš replied

    Hi Warzone,

    You can check out how to create MySQL VIEW on this video 



    Best regards.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables