我正在为内部连接的 SQL 查询而苦苦挣扎。我想拥有它,以便它加入与 $user_id 不同的字段。希望这是有道理的,这可能更容易理解:
if ($user_id = wallfriends.mem_id_from) {
INNER JOIN wallfriends ON wallusers.mem_id = wallfriends.mem_id_to
} else if ($user_id = wallfriends.mem_id_to) {
INNER JOIN wallfriends ON wallusers.mem_id = wallfriends.mem_id_from
}
我当前的查询:
SELECT * FROM wallusers
INNER JOIN wallfriends ON wallusers.mem_id = wallfriends.mem_id_from
WHERE ((wallfriends.mem_id_from =".$user_id.") OR (wallfriends.mem_id_to =".$user_id.")) AND wallfriends.confirm=1
提前致谢