SELECT F.status, U.username, U.email
FROM users U, friends F
WHERE
CASE
WHEN F.friend_one = '$user_id'
THEN F.friend_two = U.user_id
WHEN F.friend_two= '$user_id'
THEN F.friend_one= U.user_id
END
AND
F.status='1';
$ sql =" SELECT F.status,U.username,U.email" 。 "来自用户U,朋友F" 。 "在哪里" 。 " CASE" 。 "当F.friend_one = $ friend_one" 。 "那么F.friend_two = U.user_id" 。 "当F.friend_two =' *' " 。 "那么F.friend_one = U.user_id" 。 "结束" 。 " AND F.status =" 。 $之一; $ result = $ pdo-> query($ sql);
我自己想通了所有想要帮助的人。
答案 0 :(得分:0)
$sql = "SELECT F.status, U.username, U.email" .
" FROM users U, friends F" .
" WHERE " .
" CASE " .
" WHEN F.friend_one = $friend_one" .
" THEN F.friend_two = U.user_id" .
" WHEN F.friend_two= '*' " .
" THEN F.friend_one= U.user_id" .
" END " .
" AND F.status = " . $one;
$ result = $ pdo-> query($ sql);