0
I have a problem which is this, in the mysql i have a table portaria
who has a Fk_key
with the table usuario
, which is who authorizes, and, a relation N to N with the table usuario
for those who enter by the ordinance (because, can be two people at the same time) Table: usuarionportaria_solicitante
that way I would have an SQL with something like this:
SELECT ups.usuario_usuario_id, portaria.fk_quem_registra FROM portaria
INNER JOIN usuarionportaria_solicitante as ups
ON portaria.portaria_id = ups.portaria_portaria_id
INNER JOIN usuario as usuario
ON usuario.usuario_id = ups.usuario_usuario_id
On my return comes 2 requesting users just as expected from the two records there, however I want to return the names instead of the ids
, my obstacle is the portaria.fk_quem_registra
, I want you to return something like:
usuarios_solicitantes | quem_registrou
José Carlos | Froslass
Willian da Silva | Froslass
If possible, only with the INNER
, LEFT
, RIGHT
, .... JOIN
would be better for learning, I know that a sub-query
would solve, I hope you understand, wanted to make this relationship between each user and their id
through the INNER JOIN
or any other JOIN
.
Assuming in your table
usuario
there is a fieldnome_usuario
just replaceups.usuario_usuario_id
forusuario.nome_usuario
.– anonimo
In fact she has only the id
– Froslass
And then from where could you get the name? You can only recover from your database the data that exists there.
– anonimo
Through the user table, there contains the id/ user name relationship, only, I’m trying to make relationship with INNER JOIN for this, and at the same time I have 2 fields to return with different users in the case: Who Requests and Who Registers, but both are id’s of the Users table
– Froslass
can you answer my question? https://answall.com/questions/469237/identificar-registrations-sequentialof each user
– JavaScript