I'm getting this error after passing a variable containing the query inside the FROM(). The query works on workbench but not on php.
This is the error:
["Error in Selecting ","Error in Selecting You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')cnt' at line 1 SELECT SUM(counting) FROM()cnt"]
And the variable that generates the error:
$summ = "SELECT SUM(count) FROM($resFinalQuery)cnt";
$resFinalQuery content:
(SELECT 'schema1' as 'Schema', MIN(concat(DATEIN, ' ', HOURIN)) as DATEHOUR, COUNT(*) as counting FROM schema1.calls WHERE STATE = 17 AND LEVEL = 1)
UNION ALL
(SELECT 'schema2' as 'Schema', MIN(concat(DATEIN, ' ', HOURIN)) as DATEHOUR, COUNT(*) as counting FROM schema2.calls WHERE STATE = 17 AND LEVEL = 1)
EDIT: I solved this thank you, i had done the check before but forgot to put my code inside the if brackets.