Database Reference
In-Depth Information
Figure 11-56
Continued
(d) XML Schema
(e) Graphical representation of the XML Schema
Multitable SELECT with FOR XML
FOR XML SELECT statements are not limited to single-table SELECTs—they can be applied
to joins as well. For example, we can use the following SQL join query to produce a list of VRG
customers and the artists they are interested in:
/* *** SQL-Query-CH11-03 *** */
SELECT
CUSTOMER.LastName AS CustomerLastName,
CUSTOMER.FirstName AS CustomerFirstName,
ARTIST.LastName AS ArtistName
FROM
CUSTOMER,
CUSTOMER_ARTIST_INT,
ARTIST
WHERE
CUSTOMER.CustomerID = CUSTOMER_ARTIST_INT.CustomerID
AND
CUSTOMER_ARTIST_INT.ArtistID = ARTIST.ArtistID
ORDER BY
CUSTOMER.LastName, ARTIST.LastName
FOR
XML AUTO, ELEMENTS;
 
Search WWH ::




Custom Search