Jump to content

[SOLVED] Social Database Friends


Snaxpac

Recommended Posts

Hey Guys,

 

I can't seem to work my head around this one. I'm making a social site, just as a mini project. I can't work my head around this query...

 

I have 2 tables

 

Members Table and a Friends Table

 

-Members table has a member_id (unique)

 

-Friends table has a member_id, friend_id and friend_status (1 means they are friends).

 

This is what my table looks like...

 

member_id friend_id  friend_status
20              17 		1
17 		20 		1
17 		21 		1
21 		17 		1

 

What I need...

 

Let's say I'm logged on as 20 and I want to see everyone I'm not friends with.

 

So in this case, member 20 isn't friends with 21. I want to output 21's profile...

 

Here's my query so far...

 

SELECT SQL_CALC_FOUND_ROWS M.member_id, M.name, M.location, M.photoname, M.photosize

FROM as2_members M, as2_friends F

WHERE 0=0

AND M.member_id != '20'

AND F.member_id != '20'

AND F.friend_id != '20'

AND M.name LIKE '%%'

AND M.location LIKE '%%'

 

The output for this query is

 

member_id
17
21
17
21 

 

The reason its' outputting like this is because there are 2 other rows of not equal to 20.... Is function like row is not equal to?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.