我想做一个联系人页面。这是我的表结构:
Accounts Table:
1) id
2) User_id
3) Full_name
4) Username
5) Email
6) Password
Contacts Table:
1) My_id (This is the user who added friend_id)
2) Contact_id (this is the contact who was added by my_id)
3) Status
我的查询看起来像这样:
$sid = ID of user who is viewing;
$sql = "SELECT STRAIGHT_JOIN DISTINCT contacts.contact_id,
accounts.full_name FROM contacts INNER JOIN accounts
on contacts.contact_id = accounts.user_id WHERE
contacts.my_id = '$sid' OR contacts.contact_id = '$sid'";
问题是它不能以正确的方式工作。我最终在查询中看到我的名字(这意味着当我登录时,我在联系人中看到我的名字而不是联系人姓名)。
如何解决这个问题?谢谢。