MySQL - Recursive query between two tables

0

Situation: Given the profile table (Figure 01), which describes the quantity, type and year of the questions (Figure 02) for the questionnaire (Figure 03), bring up the amount of questions, and the amount specified in the profile table is of form random, without repeating and in the sequence described by the table presenting the questionnaire

How to mount this using recursion? going through the profile and filtering the issues?

I tried the following code with no success:

SELECT 
    COALESCE(CatParent.id, Questoes.id) id, 
    COALESCE(CatParent.enunciado, Questoes.enunciado) enunciado,
    perfil.tipo_id
  FROM perfil
  JOIN Questoes ON perfil.tipo_id = Questoes.tipo_id and
       Questoes.ano_id = perfil.ano_id
  LEFT JOIN Questoes AS CatParent ON Questoes.tipo_id = CatParent.id
ORDER BY RAND( )

group by id, enunciado, tipo_id
    
asked by anonymous 13.04.2018 / 22:05

0 answers