1
I would like to perform a sub-query within that query:
$ranking = $pdo->query("SELECT * FROM usuarios_emblemas GROUP BY usuario ORDER BY count(usuario) DESC LIMIT 3");
It would be to block the list of users with banned=true, I want to do the same query above but not list users with banned=true.
Could you help me?
Edit: The "banned" column is in the "users" table".
No. The banned column is in another table, called users.
– Paulo Sérgio Filho
What is the name of the other table? And which column connects the two tables?
– Roberto de Campos
What do you mean? I don’t understand the question.
– Paulo Sérgio Filho
In this table
usuario_emblemas
, probably has theid
tableusuarios
or some other field that connects the two tables, what is the name of that field? If you do not have a field for this purpose it will not be possible to make the link.– Roberto de Campos
If I understood the question, it would be the user field. The query I am using counts how many values there are with the user=x.
– Paulo Sérgio Filho
Check the images: Table users: https://prnt.sc/fs0vor || Table users_badges: http://prntscr.com/fs0w0y
– Paulo Sérgio Filho
That’s right, I changed my answer, make sure it works the way you expect it to.
– Roberto de Campos
You could help me again with this query: $ranking = $Pdo->query("SELECT * FROM topicos_comments GROUP BY author ORDER BY Count(author) DESC LIMIT 3");
– Paulo Sérgio Filho
I would be very grateful.
– Paulo Sérgio Filho
I’m not getting :x
– Paulo Sérgio Filho
The field
autor
tabletopicos_comentarios
is the same thing as the countrysideusuario
tableusuarios
?– Roberto de Campos
Yes. It’s the same.
– Paulo Sérgio Filho
This amended the reply
– Roberto de Campos
The second example did not work. Banned users continue to be listed.
– Paulo Sérgio Filho
Structure of the topical table_comments: https://prnt.sc/fs1l1r
– Paulo Sérgio Filho
Values: https://prnt.sc/fs1lbq
– Paulo Sérgio Filho
Try with the change I’ve made now. Strange not to work, the
SELECT
is the same, only changes the table ofJOIN
– Roberto de Campos
This time he showed nothing.
– Paulo Sérgio Filho
Let’s go continue this discussion in chat.
– Roberto de Campos