2
I have the following table:
I use a command SELECT
, guy:
SELECT estudante, conceito_1, conceito_2 FROM estudante WHERE etapa = '1ª'
How could I make a single select to catch the 2nd and 3rd steps too?
And I’d like SQL to generate:
2
I have the following table:
I use a command SELECT
, guy:
SELECT estudante, conceito_1, conceito_2 FROM estudante WHERE etapa = '1ª'
How could I make a single select to catch the 2nd and 3rd steps too?
And I’d like SQL to generate:
2
Imagining that your table is called Estudante
, this can be done with some Queries:
select e.estudante,
a11.conceito_1, a11.conceito_2, a11.etapa,
a22.conceito_1, a22.conceito_2, a22.etapa,
a33.conceito_1, a33.conceito_2, a33.etapa
FROM Estudante e
JOIN
(
SELECT estudante, conceito_1, conceito_2, etapa
FROM Estudante where etapa = '1a'
) AS a11
ON e.estudante = a11.estudante
JOIN
(
SELECT estudante, conceito_1, conceito_2, etapa
FROM Estudante where etapa = '2a'
) AS a22
ON e.estudante = a22.estudante
JOIN
(
SELECT estudante, conceito_1, conceito_2, etapa
FROM Estudante where etapa = '3a'
) AS a33
ON e.estudante = a33.estudante
GROUP BY e.estudante
You can see working here on this link: http://sqlfiddle.com/#! 9/f8e0e/1
I couldn’t think of a query that works independent of the number of steps, without adding a new subquery manually.
At the time of typing I forgot the table FROM. The problem I want to take the concepts of all students and then manipulate them. Ex.: Maria, conceito_1 (1st stage), conceito_1 (2nd stage), conceito_2 (1st stage), conceito_2 (2nd stage), so on. How could I take all the students and concepts and manipulate them?
@Luissouza, unfortunately I could not understand... edit your question illustrating better what you would like as a result.
I edited the question. I think now we can better understand.
Oops, it’s kind of working, I’ll fix it.
Now is correct.
Perfect! Thank you!
@Luissouza , legal! : D Could you mark my answer as the solution? See how to make a tour! Thank you!
Browser other questions tagged php mysql sql
You are not signed in. Login or sign up in order to post.
The purpose of the consultation is to show everything but the stage?
– emanuelsn