嗨,我目前正在编写一些代码,在从数据库中检索结果之前需要一个 if。
情况是,如果interacterID 不为NULL,则按它过滤,见下文
SELECT *
FROM status
WHERE type != "3"
AND userID = "'.$userID.'"
AND
(
interacterID IN ( #IF interacterID is null I want to skip this AND
SELECT userID
FROM userFriends
WHERE (
userFriends.userID = "'.$currentUserID.'"
OR userFriends.interacterID = "'.$currentUserID.'"
)
AND status = "1"
)
)
ORDER BY addedDate DESC
LIMIT 1
在此先感谢您的帮助。