Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL parsing error in phpMyAdmin ("This type of clause was previously parsed")

I have the following SQL query:

SELECT SUM(tmp.mval), tmp.timekey FROM
(SELECT teghamas, 
        MAX(arzheq) as mval, 
        ceil(UNIX_TIMESTAMP(zhamanak)/(60 * 60)) AS timekey
   FROM `masnakcutyun`
   LEFT JOIN teghkentron ON `masnakcutyun`.`teghKentronId`=`teghkentron`.`teghKentronId` 
  WHERE teghkentron.hamaynq="London" group by timekey, teghkentron.teghamas)         
AS tmp
GROUP BY tmp.timekey

It works fine in phpMyAdmin. But there's a warning there saying:

"This type of clause was previously parsed (near select)".

Can you guess what is the problem? The query can execute and return the expected results.

like image 249
Khachik Sahakyan Avatar asked Mar 13 '23 16:03

Khachik Sahakyan


2 Answers

It seems to be a phpMyAdmin parser bug, see the issue on github, the query itself is valid.

like image 50
pilsetnieks Avatar answered Mar 15 '23 10:03

pilsetnieks


MySQL allow write subquery in from clause, but this is know issue, you can create view and use it :

CREATE VIEW viewname AS (SELECT teghamas, 
    MAX(arzheq) as mval, 
    ceil(UNIX_TIMESTAMP(zhamanak)/(60 * 60)) AS timekey
    FROM `masnakcutyun`
    LEFT JOIN teghkentron ON `masnakcutyun`.`teghKentronId`=`teghkentron`.`teghKentronId` 
    WHERE teghkentron.hamaynq="London" group by timekey, teghkentron.teghamas) ;

SELECT SUM(mval) as MySum, timekey 
FROM viewname
GROUP BY timekey
like image 42
Adam Silenko Avatar answered Mar 15 '23 11:03

Adam Silenko