I have this table
|ID|nombre |
|1 |Ricardo|
|2 |Roberto|
|3 |Brayan |
And then it's another one
|ID_comment|Escrito_por|dirigido a|Comentario |
|1 |2 | 1 | Comentario|
|2 |3 | 1 | Comentario|
|3 |2 | 1 | Comentario|
|4 |4 | 1 | Comentario|
|5 |3 | 1 | |
My problem is that I do not know in what way I can show the name of the person who directs the comment that is fk of the users table with the other data. I tried with join or a subquery,
The result I'm looking for is:
| ID_comment | Written_by | directed to | Comment | name of who wrote |
but in the field of the person who 'written by' the value can be repeated. to which the query bounces the first 4 fields correctly but the name of the person who wrote bounces a repeated query
| ID_comment | Written_by | directed to | Comment | name of who wrote |
| 1 | 2 | 1 | Comment | Ricardo |
| 2 | 2 | 1 | Comment | Ricardo |
| 3 | 2 | 1 | Comment | Ricardo |
As you see the comment 2 repeats the name of Ricardo when he did not write it. Here is my select:
SELECT nombre
, Id_comment
, commentario
, dirigido a
FROM comments
FULL JOIN users
ON users
. escrito por
= 2
probe with all the joins ah add another table but it keeps repeating that value and I do not know how to fix it.