Нещо подобно може да работи
LEFT JOIN challengesRead
ON challenges.userID = CASE
WHEN challenges.userID = $var THEN challengesRead.userID
WHEN challenges.opponentID = $var THEN challenges.opponen END
Нещо подобно може да работи
LEFT JOIN challengesRead
ON challenges.userID = CASE
WHEN challenges.userID = $var THEN challengesRead.userID
WHEN challenges.opponentID = $var THEN challenges.opponen END