4
In a query in Mysql I need to select the results and sort the results based on the amount they repeat using the column id_livro, for example:
My table comments:
+----------------+-------------+
| id_livro       | comentario  |
+----------------+-------------+
|     1          | Com1        |
+----------------+-------------+
|     1          | Com2        |
+----------------+-------------+
|     2          | Com3        |
+----------------+-------------+
|     3          | Com4        |
+----------------+-------------+
|     3          | Com5        |
+----------------+-------------+
|     3          | Com6        |
+----------------+-------------+
In this way I would like to organize a research that returns the most commented books in descending order from the most commented ones to the less commented ones that in the case would be the book 3, 2 and the 1
What would that consult look like? Ps: Results need to be grouped by book id as well.
Thanks Sorack exactly what I needed, I will open another question more or less the same way, I hope it can help me there also you always save me when the subject is mysql
– Leo Letto