Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > XML output & mu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 15810 of 17437
Post > Topic >>

XML output & multiple SELECT queries

by peter@[EMAIL PROTECTED] (Peter Billen) Jun 14, 2008 at 11:50 AM

Dear PostgreSQL users,

I would like to ask a question about outputting data as XML. Say I have
two
tables:

team(integer id, text name);
player_of_team(integer id, integer team_id, text name); (team_id is FK to
team.id)

I would like to query both tables to get following example XML output:

<team name="Real Madrid">
     <players>
         <name>Garcia</name>
         <name>Robinho</name>
     </players>
</team>

Is this possible in one query? I'm thinking about something like this, but
I
haven't figured it out so far:

SELECT XMLElement(name team, XMLAttributes(name as name), SELECT
XMLElement(name
players, XMLForest(name)) FROM player_of_team WHERE team_id = t.id) FROM
team t
WHERE t.name = 'Real Madrid';

In other words, is it possible to nest multiple SELECT queries in the XML
output
functions?

Thanks in advance. Kind regards,

Peter


-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 2 Posts in Topic:
XML output & multiple SELECT queries
peter@[EMAIL PROTECTED]   2008-06-14 11:50:39 
Re: XML output & multiple SELECT queries
peter_e@[EMAIL PROTECTED]  2008-06-15 18:49:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 2:21:34 CST 2008.