0
I need to create a select
who picks up the id's
of two tables, unite them and show me the last record of the two together. I tried so:
SELECT DISTINCT p.cod_mobilibus, p.nome, q.dt_acesso
FROM pr_pontos p
RIGHT JOIN pr_qr_pontos q ON p.cod_mobilibus = q.cod_mobilibus
ORDER BY q.dt_acesso DESC
My biggest problem is that the results I receive cannot be equal.
Structure table 1
id_acesso / cod_mobilibus / dt_acesso
Structure table 2
id_ponto / cod_mobilibus / nome / endereco / cidade / bairro / codigo
can post the structure of the two tables?
– Thiago Magalhães
Oops, updated the post.
– Mickael Rocha
as such the results cannot be equal?
– Thiago Magalhães
I will explain in more detail. I have several qrcodes where the person accesses and takes her to a website. This entry records the value in the database in table 1. In table 2 are the definitions of the "points" of table 1. So I need the last record of each point, but cod_mobilibus cannot be repeated, because two users can access this qrcode, but I just want the most recent access of it.
– Mickael Rocha