EDIT by:lawrence.
我现在谈谈正确的问题。
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)
回答问题
我需要帮助加入我的朋友和用户表的成果。
这就是我的朋友们认为的。
id user_id1 user_id2
1 | 2 | 3
1 | 2 | 4
1 | 2 | 5
1 | 6 | 2
www.un.org/Depts/DGACM/index_spanish.htm 用户表
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.
如果两行各有关系,但一意想这样做,则罚款。
SELECT * FROM friends, users WHERE friends.user_id1 = $profileID AND friends.user_id2 = users.id ORDER BY friends.id DESC LIMIT 16
你们是谁? 类似情况
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
我希望我明确表示: