0
Hello, I’m having a little doubt about SQL since I don’t understand anything about it. I have a table where I am making a select to see the updates with a subquery and do a LEFT JOIN here is the code:
SELECT a.id, a.nome,
(SELECT COUNT(c.id) FROM postagens as c WHERE c.data_cadastro >
b.data_acesso AND c.id_categoria = a.id AND deletado = 0) as atualizacoes
FROM postagens_categorias as a
LEFT JOIN postagens_categorias_view as b ON a.id = b.id_categoria
WHERE a.deletado =0 AND a.id != 3 ORDER BY a.nome DESC
And it gives this result here:
The data I would like would be:
Projetos 25
Estágios 24
Divulgação 21
I believe I should use a GROUP BY somewhere, if I use DISTINCT at first it keeps duplicating the values only in place of NULL, 0.
Here is the table of posts_categories:
Postings:
How do I do that part?
already tried with distinct and group by in column updates?
– Maycon F. Castro
I believe you have to do with INNER JOIN.
– Lucas Brogni
Detail your tables in question, will facilitate our understanding of the problem to give a possible answer. With the code you put in, I suppose it’s more interesting you take out the subselect and make a group by.
– Felipe J. R. Vieira