0
I am making a query in the database and I am having difficulties with data duplications, so far, this is my query:
SELECT * FROM tec_postagens tp
INNER JOIN tec_historico_status th ON tp.protocolo=th.protocolo
WHERE tp.protocolo = '1168'
ORDER BY tp.protocolo DESC, tp.datahora DESC
the result is :
the first table is tec_postagens
, the second is tec_historico_status
, I need to show all posts along with the data from tec_historico_status
both have the same protocolo
what differentiates is the datahora
I need to show by order of datahora
thank you.
In my view it is not wrong. Because you are linking everything in a single query. These duplicities must be adjusted using the programming language in their application.
– Antony Alkmim
You just don’t want duplicate data to appear? Can’t use DISTINCT?
– Rene Sá
never used DISTINCT @Renesá , could help me?
– Furlan
Thus:
SELECT DISTINCT * FROM tec_postagens tp
INNER JOIN tec_historico_status th ON tp.protocolo=th.protocolo
WHERE tp.protocolo = '1168'
ORDER BY tp.protocolo DESC, tp.datahora DESC
With DISTINCT, if there are multiple identical results, evaluating the sequence by ORDER BY, it returns only one. @Rene, put the solution as answer.– Gustavo Cinque
was the same result @Gustavocinque
– Furlan
Furlan where there’s repetition, I don’t understand...
– Jorge B.
in the column posting @Jorgeb.
– Furlan
Try to explain your problem better in the question. It is not possible to realize what you want.
– Jorge B.