I have three tables namely Customer, Download, Games in portgres with following fields,
|-----------|
| Customer |
|-----------|
| cust_ID |
|-----------|
| name |
|-----------|
| country |
|-----------|
|-----------|
| Download |
|-----------|
| cust_ID |
|-----------|
| game_ID |
|-----------|
| version |
|-----------|
|-----------|
| Games |
|-----------|
| game_ID |
|-----------|
| name |
|-----------|
| price |
|-----------|
i am in need to export the table data into an xml format as below,
<customers>
<customer>
<id>1</id>
<name>value</name>
<country>value</country>
<games>
<game>
<game_id>1</game_id>
<name>value</name>
<price>value</price>
<download_ver>value</download_ver>
</game>
<game>
<game_id>3</game_id>
<name>value</name>
<price>value</price>
<download_ver>value</download_ver>
</game>
</games>
</customer>
I will have multiple customer entities under customers table. the column under the node is from Download table linked by game_id field.
select XMLELEMENT(name "warehouses",
XMLAGG(
XMLELEMENT(name "warehouse",
XMLFOREST(
w.w_id,
w.w_name,
w.w_country))))
FROM warehouse w
Above code can query warehouse nodes, but how do i incorporate games node?