Hello! There is a friends table, fields in it: id, user_1, user_2. user_1 This is the user who offered the friendship, and user_2 who agreed. It is necessary to make a sample that will show the user's friends, but we do not know who the user is ... the initiator of the friendship or the one who agreed to it.
In my opinion, your table lacks another field "status". When someone offers friendship, a record is made in this table. user_1 is the one who offered the friendship, user_2 is the one to whom the friendship was offered and the status is await. If the second agrees, then the status is changed to friendship_forever. Then you will not get confused, because user_1 - it will always be the first to offer friendship.
PS I figured it out, but what difference does it make - I suggested friendship or agreed with the proposal? Indeed, in any case, two people become friends and, accordingly, what is needed in the list of friends to show everyone.
"select * from friends where user_1=$id or user_2=$id"
"select user_1 from friends where user_2=$id union all select user_2 from friends where user_1=$id"
To unite those who responded to Vasya's suggestions, and those to whose proposals Vasya agreed.
$query = sprintf( 'SELECT `user_1` AS userid FROM `friends` WHERE `user_2`=%1$d UNION SELECT `user_2` AS userid FROM `friends` WHERE `user_1`=%1$d', $id );