Here you need to join the user table twice with each user_a and user_b :
Try this query:
SELECT u.name FROM Users u JOIN friends f ON u.id = f.user_b JOIN Users u1 ON u1.id = f.user_a WHERE u1.name = 's1';
Result:
ββββββββ β NAME β β βββββββ£ β s2 β β s3 β ββββββββ
Change In the query (which you tried) you used the external table identifier and the name in the subquery. Therefore, you had to use the identifier and name of the subcategory as follows:
select a.name from users a, friends b where a.id=b.user_b and b.user_a IN (select id from users where name='s1');
source share