Table dating_users
:
user_id | username
---------+----------
11 | taimoor
13 | jacob
14 | pi
(3 rows)
Table dating_likes
:
like_id | user_id | liked_user
---------+---------+------------
54 | 11 | 13
56 | 13 | 11
57 | 11 | 14
(3 rows)
I want to find likes where a user has liked someone, and that someone has liked them. Here's my query:
select like_id from dating_likes where user_id = 11 and exists(select like_id from dating_likes where liked_user = 11);
Result:
like_id
---------
54
57
(2 rows)
That should have resulted with only the first row, since 54
is a like where the user_id = 11
and there is a like 56
where liked_user = 11
. Like 57
should not show up, since it's not mutual - all that's true is that the user_id
is 11.