social networking database design and retrieve data
Posted: Mon Jul 20, 2009 1:50 pm
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!!!
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!!!