XML output & multiple SELECT queries

Поиск
Список
Период
Сортировка
От Peter Billen
Тема XML output & multiple SELECT queries
Дата
Msg-id 20080614115039.90n2ocnylxnoss8w@webmail.clueless.be
обсуждение исходный текст
Ответы Re: XML output & multiple SELECT queries  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-general
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


В списке pgsql-general по дате отправления:

Предыдущее
От: D Galen
Дата:
Сообщение: Re: Overloading
Следующее
От: "Ciprian Dorin Craciun"
Дата:
Сообщение: Re: Backup using GiT?