MYSQL triggers an SQLSTATE[42S02] error while processing a subquery with the table called through alias
"UPDATE call_log AS c1 INNER JOIN call_log AS c2 ON c1.id = c2.id SET c1.end ='".$reponse."' WHERE c1.id = (SELECT MAX(c2.id) FROM (SELECT * from c2 WHERE c2.num =".$numero." ) derivee )";
The desired outcome is to update the last matching line containing the $num variable in call_log table. As MYSQL prevents to do subqueries based on the same table I used aliases to refer to those tables as recommended here
mySQL error: #1248 - Every derived table must have its own alias
or here What is the error "Every derived table must have its own alias" in MySQL?
The Error I get is:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ERP.c2' doesn't exist'