Lawrence: tarafından EDIT.
Ben şimdi doğru sorgu var
select * from users, friends where (users.id=friends.user_id1 and friends.user_id2=$profileID) or (users.id=friends.user_id2 and friends.user_id1=$profileID)
Soru cevap
Ben arkadaşlarıma ve kullanıcıların tablodan sonuçlarını katılmadan biraz yardıma ihtiyacım var
Bu benim arkadaşlarım tablo benziyor ne
id user_id1 user_id2
1 | 2 | 3
1 | 2 | 4
1 | 2 | 5
1 | 6 | 2
Users table
id name
2 | sarah
3 | emma
4 | lawrence
5 | cynthia
6 | suzie
I could easily just have two rows for each relation and do a simple query.
But i prefer having one row per relation,
So lets assume that we are watching page member.php?profile=2
and there is a list of friends, what does the query look like.
I ilişki başına iki satır var ama ben o istemiyorsanız, bu iyi çalışır ....
SELECT * FROM friends, users WHERE friends.user_id1 = $profileID AND friends.user_id2 = users.id ORDER BY friends.id DESC LIMIT 16
Beni alır mıyım? gibi birlikte bir şeyler
SELECT * FROM friends,users WHERE friends.user_id1 = $profileID AND ALSO WHERE friends.user_id2 = $profileID AND THEN GET FROM users WHERE users.id = friends.user_id1 AND ALSO WHERE users.id = friends.user_id2
Kendimi açıkça yapılan umuyoruz