日期:2014-05-16  浏览次数:20383 次

Oracle 关联自己
SELECT T.ID,
       CASE
         WHEN T.PARENT_ID = 0 THEN
          T.NAME
         ELSE
          T2.NAME
       END AS NAME,
       CASE
         WHEN T.PARENT_ID = 0 THEN
          T.R
         ELSE
          T2.R
       END AS R,
       D.NAME AS RNAME
  FROM INFO T
  LEFT JOIN INFO T2
    ON T.PARENT_ID = T2.ID
  LEFT JOIN DOMAIN D
    ON (T.R || T2.R) = D.ID

?