diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php
index 8783e0894..4588e19e4 100644
--- a/libraries/sqlparser.lib.php
+++ b/libraries/sqlparser.lib.php
@@ -1446,6 +1446,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$in_group_concat = FALSE;
$first_reserved_word = '';
$current_identifier = '';
+ $unsorted_query = $arr['raw']; // in case there is no ORDER BY
for ($i = 0; $i < $size; $i++) {
//DEBUG echo "Loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
";