I have this table in 'MariaDB [accounts] >
SELECT * FROM mercado WHERE nome_mercado LIKE 'extra';
+----+--------------+-------------+-----------+-----------+-------+
| id | nome_mercado | data_compra | produto | descricao | preco |
+----+--------------+-------------+-----------+-----------+-------+
| 1 | Extra | 2017-07-12 | Coca Cola | Coca | 3.00 |
| 2 | Extra | 2017-07-12 | Sucos | Suco | 3.50 |
| 3 | Extra | 2017-07-12 | Frios | Frios | 7.80 |
| 11 | extra | 2017-07-28 | Suco | Teste | 5.90 |
| 12 | extra | 2017-07-28 | Bolacha | | 2.49 |
+----+--------------+-------------+-----------+-----------+-------+'
I would like to return only the products with the most recent dates, ie just these:
| 11 | extra | 2017-07-28 | Suco | Teste | 5.90 |
| 12 | extra | 2017-07-28 | Bolacha | | 2.49 |
I used this select, but it does not return anything:
MariaDB [accounts] >
SELECT * FROM mercado WHERE nome_mercado LIKE 'extra' =
(SELECT data_compra FROM mercado ORDER BY data_compra DESC LIMIT 1);
Empty set, 5 warnings (0.00 sec)