1

我有这样的桌子

id     name     pid
101   Animal    null
102   Dog       101
103   pug       102

我想要动物>狗>哈巴狗

4

1 回答 1

0

我认为这样的东西适合你,因为我不知道你的 RDBMS 也许它需要一些改变

WITH  NewAnimal
        AS (SELECT  CAST((a.Desc + '>' + t.Name) AS VARCHAR(1000)) AS "Desc"
             FROM    Table AS t
             JOIN NewAnimal AS a
             ON t.PID = a.id
           )
SELECT * FROM NewAnimal
于 2013-02-27T06:43:07.630 回答