I'm trying to delete data (where the stock is equal to zero and the discount value is less than the total average discount value) with this query:
DELETE FROM veiculo WHERE estoquetotal = 0 AND valordesconto < (SELECT AVG(valordesconto) FROM veiculo);
However, it is returned to me "You can't specify target table 'veiculo' for update in FROM clause"
.
I've already researched a solution here, but I'm not able to apply any of them in my query (I'm new to MySQL database). Of the answers I researched, they had to do with JOIN
.
Thank you in advance.