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
https://forums.phpfreaks.com/topic/106886-solved-social-database-friends/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.