I have the next 2 tables:
Users
+----+-----------+
| id | user_name |
+----+-----------+
| 18 | Andrei |
| 19 | Gicu |
| 20 | Gigel |
+----+-----------+
Requests
+----+-----------+---------+
| id | from_user | to_user |
+----+-----------+---------+
| 3 | 18 | 19 |
| 4 | 18 | 20 |
| 5 | 20 | 19 |
+----+-----------+---------+
And i make the following query:
SELECT requests.from_user
FROM requests
WHERE
(SELECT id FROM users WHERE users.user_name='Gicu')=requests.to_user;
which returns:
+-----------+
| from_user |
+-----------+
| 18 |
| 20 |
+-----------+
My question now is ... how to get the user names associated to these ids (18 and 20) What should i add to the query? (I'm not familiar to joins/union and those other stuff)