The data is drawn from the question table, followed by JOIN's
It is necessary that when question.category> 0 was:
LEFT JOIN detailtousers b ON b.idDetailToUsers = a.QuestionIdUser Otherwise, another JOIN
Need something like this:
IF a.QuestionToUser > 0 THEN LEFT JOIN detailtousers c ON c.idDetailToUsers = a.QuestionToUser ELSEIF a.QuestionToUser = 0 THEN LEFT JOIN detailtousers c ON c.idDetailToUsers = d.AnswerToQuestionIdUser ENDIF