I have a question in SQL that is as follows: I have two tables, the parent table, and the daughter table, where the daughter table receives the id
of the parent table as foreign key, however, I do not know how to show the data entered in an organized way. I need the data to appear on the screen as follows:
Title 1 of parent table: Data 1 of daughter table related to id 1 of parent table Given 2 of the daughter table related to the id 1 of the parent table Daughter table data 3 related to parent table id 1
Title 2 of the parent table: Given 1 of the child table related to id 2 of parent table Given parent table 2 of parent table id 2
And so on, however, my data is appearing on the screen as follows:
Title 1 of the parent table: Given 1 of the child table related to id 1 of parent table
Title 1 of the parent table: Given 2 of the child table related to id 1 of parent table
Title 1 of parent table: Data 3 of daughter table related to id 1 of parent table
Title 2 of the parent table: Given 1 of the child table related to id 2 of parent table
Title 2 of the parent table: Given 1 of the child table related to id 2 of parent table
The select looks something like this:
SELECT *
FROM pai
LEFT JOIN filha ON (pai.id_tabelaPai = filha.id_tabelaPai)