XML and SQL server

admin

Administrator
Staff member
Hello,We are investigating a system that will build files from a definition storedin SQL server.Now the original query looked something like:SELECT F.*, S.*, P.*, V.*FROM Files F INNER JOIN Sections S ON F.ID = S.FileID LEFT JOIN Properties PON S.ID = P.SectionID LEFT JOIN Values V ON S.ID = V.SectionIDThe resulting XML was:<F ...><S ...><P ...><V .../><V .../><V .../></P><P ...><V .../><V .../><V .../></P></S></F>But we want something like:<F ...><S ...><P ... /><P ... /><V ... /><V ... /><V ... /></S></F>To work around this problem we now use the following 2 queries and use theappenChild method to create the second model.SELECT F.*, S.*, P.*FROM Files F INNER JOIN Sections S ON F.ID = S.FileID LEFT JOIN Properties PON S.ID = P.SectionIDSELECT V.*FROM Values WHERE V.SectionID = @SectionIDIs there a way to avoid iterating through all sections?tia,Peter Vervoorn
 
Back
Top