I want to execute the following SQL statement in PhP. I have simplified it below. I would like to know the MySQL modifications to make it work. I tried a few like giving aliases to the tables but it did not work:
update T1 set col1 = 500
where col2 = 12345 and
col3 = (select max(col3) from T1 where col2 = 12345)
I want to update a record which has the max value for one column. There is only one table involved in the entire query. I am using PDO, if that is relevant.
The error given is:
#1093 - You can't specify target table 'T1' for update in FROM clause