Well, let's try to keep this simple.
You're trying, essentially, to find a way to connect two users together.
Şeyleri basit tutmak için çalışıyor ve kesinlikle bu bunu yapmanın en iyi yolu olduğunu ima etmiyorum, çünkü ben bunu hakkında gitmek için easiest yolu (users_friends) yeni bir tablo oluşturmak için olduğunu düşünüyorum Aşağıdaki alanlar: (User_id) ve (friend_id).
Well, so let's say my user_id is 5.
Your user_id is 10.
I want to add you as my friend, therefore I'd add an entry to that newly created table with the following values:
user_id = 5, friend_id = 10.
Yani, sen bütün arkadaşlarıma göstermek istiyorum diyelim, sen gibi bir sorgu çalıştırabilir:
SELECT * FROM `users` WHERE `user_id` IN ( SELECT `friend_id` FROM `users_friends` WHERE `user_id` = '5' );
Tabii ki, bir arkadaş çıkarmadan kolay, yapmanız gereken tüm yeni oluşturulan kayıt tablodan silmek ...
DELETE FROM `users_friends` WHERE `user_id` = '5' AND `friend_id` = '10';
Ve puf, sen artık benim arkadaşım aniden değilsin ;)
So yeah, these are the basics.
I'd try this solution before moving on to a solution which will allow you more flexibility.