Help to consult several tables

0

I need to extract the data from several tables, for which I made a selection of the question to which the people signed up and the ID of that question corresponds to id 22 of the table "Responses". Now, once filtered, I need to know who were the persons with the first and last names that pointed to this question and if you can know to which course too. I will appreciate your help. select * from Respuestas where PreguntaId = '22'

select Respuestas.PreguntaId from Respuestas, CursoPlaneadoParticipantes, CursoPlaneadoes, Participantes where Respuestas.CursoPlaneadoParticipanteId=CursoPlaneadoParticipantes.id

Only from id 22

    
asked by user3802081 24.01.2018 в 14:54
source

2 answers

0

You should explain and organize your question a bit better ... Still, let's see if I found out and we solved it.
I understand that the only thing you need is Nombre and Apellido of the participant in the course corresponding to Answer 22 and the Nombre of that course, yes?
It seems that you only need to make a JOIN of all the tables by the correct identifiers and take out in the SELECT the fields you need:

SELECT Participantes.Nombre,Participantes.Apellido,Cursos.Nombre AS Curso
FROM Respuestas
INNER JOIN CursoPlaneadoParticipantes  
    ON CursoPlaneadoParticipantes.id=Respuestas.CursoPlaneadoParticipanteId
INNER JOIN Participantes  
    ON Participantes.id=CursoPlaneadoParticipantes.ParticipanteId
INNER JOIN CursoPlaneados  
    ON CursoPlaneados.id=CursoPlaneadoParticipantes.CursoPlaneadoId
INNER JOIN Cursos  
    ON Cursos.id=CursoPlaneados.CursoId
WHERE Respuestas.Preguntaid=22
    
answered by 25.01.2018 в 10:03
0

Hello, you could provide more information about what you have between the tables, based on the images you shared, the only tables that are related are "participant courses" and "courses".

To be able to select information from several tables it is necessary to have a relationship between them.

    
answered by 25.01.2018 в 17:56