Hi I am currently coding something which requires an if before the results are retrieved from the database.
The case is that if the interacterID is not NULL then filter by it, see below
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
Thanks in advance for the help.