I have two tables as below
Table students
PersonID firstName
1 John
2 Mike
Table Marks
mark_id person_id subject marks
1 1 English 50
2 1 Maths 75
the below query give the xml as below
select XMLElement( "Students" ,
(select XMLAgg( XMLElement("Student" ,
XmlElement( "Student_id","id") ,
XmlElement( "First_Name","firstname")
))
FROM students )
)
AS "RESULT"
From dual
<Students>
<Student>
<Student_id>1</Student_id>
<First_Name>John</First_Name>
</Student>
<Student>
<Student_id>2</Student_id>
<First_Name>Mike</First_Name>
</Student>
<Students>
Now I need to do a left join the table students
with Marks
and create a xml like below
<Students>
<Student>
<Student_id>1</Student_id>
<First_Name>John</First_Name>
<Marks>
<subject>English</subject>
<mark>50</mark>
<subject>Maths</subject>
<mark>75</mark>
</Marks>
</Student>
<Student>
<Student_id>2</Student_id>
<First_Name>Mike</First_Name>
<Marks/>
</Student>
<Students>
how can i achieve if i write the select query it will return two rows for the first student since it has 2 rows to join in the second mark table.