我怎樣才能加入users
與users_friends.user_id
時user_id = '" . $user_id . "'
MySQL的編碼問題
而且隨着users_friends.friend_id
加入users
時friend_id = '" . $user_id . "'
如果user_id = '" . $user_id . "'
INNER JOIN users ON users_friends.user_id = users.user_id
如果friend_id = '" . $user_id . "'
INNER JOIN users ON users_friends.friend_id = users.user_id
當前的MySQL代碼。
SELECT COUNT(user_id) as friends
FROM users_friends
WHERE (user_id = '" . $user_id . "'
OR friend_id = '" . $user_id . "')
AND friendship_status = '1'
使用PHP'mysql_real_escape_string'功能請。你的代碼似乎很容易被SQL注入! – Benoit 2010-10-14 13:28:22