Assume that I have a table of products and that there are only 2 fields; id and purchase_date. I want to delete the last product that was bought in 2019. I have tried to do it using the following query:
DELETE FROM products
WHERE id = (SELECT id
FROM products
WHERE purchase_date LIKE '2019%'
ORDER BY purchase_date DESC
LIMIT 1);
Unfortunately, the error that is written in the title appears. I know that this error is a known error and I have tried to look for solutions. I have looked over here and here, however, I couldn't understand how to change my query so it will work correctly.
I will be glad for help and explanations. Thanks in advance.