//queries to manage hierarchical or parent-child relational rows Example
WITH q AS
(
SELECT *
FROM MKT1
WHERE ParentID =4
UNION ALL
SELECT m.*
FROM MKT1 m
JOIN q
ON m.parentID = q.PersonID
)
SELECT *
FROM q WHERE 1=1
WITH q AS
(
SELECT *
FROM MKT1
WHERE ParentID =4
UNION ALL
SELECT m.*
FROM MKT1 m
JOIN q
ON m.parentID = q.PersonID
)
SELECT *
FROM q WHERE 1=1
No comments:
Post a Comment