Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

I have the following tables with the following contents:

create table Employees (EmployeeID int primary key, EmployeeName varchar(10));

insert into Employees values (1, 'Employee1');

insert into Employees values (2, 'Employee2');

insert into Employees values (3, 'Employee3');


create table Orders (EmployeeID int, OrderName varchar(10) primary key);

insert into Orders values (1, 'Order1');

insert into Orders values (1, 'Order2');

insert into Orders values (1, 'Order3');

insert into Orders values (2, 'Order4');

And I want to retrieve the following query in XML

select EmployeeName, OrderName from Orders o, Employees e where o.EmployeeID = e.EmployeeID

The question, how can I save me the repeated EmployeeNames in XML? So that to have an output like:

    <orders>

    <employeename>Employee1

    <ordername>Order1</ordername>

    <ordername>Order2</ordername>

    <ordername>Order3</ordername>

    </employeename>

    <employeename>Employee2

    <ordername>Order4</ordername>

    </employeename>

    </orders>

asked 18 Sep '19, 05:24

Baron's gravatar image

Baron
2.1k137150177
accept rate: 48%

edited 18 Sep '19, 07:47

Volker%20Barth's gravatar image

Volker Barth
40.2k361550822

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×29

question asked: 18 Sep '19, 05:24

question was seen: 697 times

last updated: 18 Sep '19, 07:47