Guest User

Untitled

a guest
Feb 26th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.72 KB | None | 0 0
  1.  
  2. Laatst had ik vergelijkbaar probleem waarbij ik hiearchy van documenttypes diende te queryen, uiteindelijk deze toch wel vrij pittige query voor MS Sqlserver geschreven:
  3.  
  4.  
  5.  
  6. WITH n(nodeId, alias,mastercontenttype,icon,thumbnail) AS
  7.    (SELECT nodeId, alias,mastercontenttype,icon,thumbnail
  8.     FROM [cmsContentType]
  9.     UNION ALL
  10.     SELECT nplus1.nodeId, nplus1.alias , nplus1.mastercontenttype, nplus1.icon,nplus1.thumbnail
  11.     FROM [cmsContentType] AS nplus1, n
  12.     WHERE n.nodeId = nplus1.masterContentType)
  13.  
  14. SELECT DISTINCT cmsContentType_1.alias,n.nodeId,n.alias,n.icon,n.thumbnail FROM n
  15. LEFT OUTER JOIN
  16. dbo.cmsContentType AS cmsContentType_1
  17. ON n.masterContentType = cmsContentType_1.nodeId
  18. ORDER BY n.nodeId
Advertisement
Add Comment
Please, Sign In to add comment