i have 2 tables:
table1
id message user
1 testing 23
2 testing again 44
3 test.. 23
5 lol 12
6 test.. 6
and
table2
id user friend
1 23 44
2 23 6
3 19 12
4 23 32
5 23 76
6 23 89
i am trying to get the messages of all users that are friends with 23 including 23
like:
id message user id user friend
1 testing 23 n n n
2 testing again 44 1 23 44
3 test.. 23 n n n
6 test.. 6 2 23 6
we can see that 12 is missing because he is not friend with 23 but only with 19
i’ve got this
SELECT *
FROM table1 AS w
INNER JOIN table1 AS f ON w.user = f.friend
WHERE (w.user = 23)
but in case 23 has messages but no friends it will return null and also this will return other friends of 23 like 76 and 89 that have no messages..
🙂 confused?
any ideas?
thanks
Try this: