social networking database design and retrieve data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
changwl8888
Forum Newbie
Posts: 1
Joined: Mon Jul 20, 2009 1:36 pm

social networking database design and retrieve data

Post by changwl8888 »

Listing 2: Selecting everyone that has you as a friend

And depending on your implementation, if you want to simply see everyone you are friends with (whether you added them, or they added you), you can use the UNION keyword to combine the results of both queries shown above (Listing 3).

SELECT DISTINCT a.*
FROM Accounts a
INNER JOIN Friends f ON a.ID = f.friendID
WHERE f.AccountID = @ID

UNION

SELECT DISTINCT a.*
FROM Accounts a
INNER JOIN Friends f ON a.ID = f.AccountID
WHERE f.FriendID = @ID



i wana ask my account table has user account details, may i know how to retrive all data of my friends using php and mysql fetch array or wat
and show it in table...please help
how is the code should write?can anyone please help me urgent!!!
User avatar
DaveTheAve
Forum Contributor
Posts: 385
Joined: Tue Oct 03, 2006 2:25 pm
Location: 127.0.0.1
Contact:

Re: social networking database design and retrieve data

Post by DaveTheAve »

Please provide database table information so we know the table and associated fields.
Post Reply