How to get my friend's ID?
My unique ID 1
The first stage is a list of all friends.
SELECT * FROM friends WHERE friends.user_from = $id OR friends.user_to = $id;
We get 2, 4, 6
The second stage is a list of all friends of my friend.
SELECT * FROM friends WHERE friends.user_from IN (SELECT friends.user_to FROM friends WHERE friends.user_from = $id) OR friends.user_to IN (SELECT friends.user_from FROM friends WHERE friends.user_to = $id);
We get 2 3, 4 7
- The third stage is how to find out my friend's ID
Received 2 or 3, 4 or 7
The fourth stage should be like this
echo $row['user_from']. ' '.$row['user_to']. '. Мой друг: '.$row['friend'];2 3. Мой друг: 24 7. Мой друг: 4

ASis the alias designation for a field; it is impossible to transfer anything to it. AndASin this request is not needed anywhere, although, of course, it should not interfere - Mikefriends.user_fromandfriends.user_toinIN()as afriend- KYRAN