I have 4 tables… users, friends, articles & article_shares (as in written)
A user can share an article they have created by simply inviting them to read it. What I’m trying find is a list of friends of the article creator (id 63) who have not been invited to share the article yet (id 34).
So, table users:
user_id - name
10 Dan
11 Doug
12 Chad
13 Ben
63 John
table friends
user_id - friends_id
63 10
63 11
63 12
63 13
table articles
article_id - user_id_creator
34 63
table article_shares
article_id - user_id_sharedWith
34 10
34 11
From the data above I want to return users with id 12 & 13.. chad & ben
Here’s what I’m trying:
select u.name, u.user_id, u.live_prof_pic from users u
join friends f on f.user_id = u.user_id
join articles a on a.user_id_creator = f.friends_id
join article_shares as on as.articl_id <> a.article_id
where ((f.friends = '63') && (a.article_id = '34'))
It is simply returning 0
Any ideas?
Give this a try,