Hello, I'm doing a facebook clone database. I have two tables, one of users and another friendship. The friendships table is a self-relationship of users as shown in the picture.
This Friendship table contains the IDs of each user and needs to select the mutual friendships between two selected users. For example:
| idUsuario1 | idUsuario2 |
| ------------- | ------------- |
| 1. | 2. |
| 2. | 3. |
| 2. | 4. |
| 1. | 3. |
I need to look up this table for the common friends of user1 and user2. That is, the return will be 3.4. But I can not properly filter the output.