Created
September 25, 2016 08:16
-
-
Save Chetan496/ceb9c14ce9b53497e8071b637f869d59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, instanceId, processModelId, GROUP_CONCAT(CONCAT_WS("=", variableName, oldValue)) AS OLDVALUE, | |
GROUP_CONCAT(CONCAT_WS("=", variableName, newValue)) AS NEWVALUE , parentVariableName FROM `Object_History` | |
GROUP BY instanceId, parentVariableName; |
You will need to take care of the length of the Strings. The concatenation may produce strings which are very long. You need to set some limit especially in case of arrays - about how many variables you are going to edit etc.
A better version:
SELECT id, instanceId, processModelId, GROUP_CONCAT(CONCAT_WS("=", variableName, oldValue) SEPARATOR ", ") AS OLDVALUE,
GROUP_CONCAT(CONCAT_WS("=", variableName, newValue) SEPARATOR ", ") AS NEWVALUE , parentVariableName FROM Object_History
GROUP BY instanceId, parentVariableName;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This shows how to group the expanded individual fields of a CDT in a single row