我要的結果是 1243 ?以這個順序展示出來 ?這個sql語句怎么寫?
12 回答

HUH函數
TA貢獻1836條經驗 獲得超4個贊
select * from (select t.*, t.ID || t.PAERNT_ID sort from table t) order by sort

冉冉說
TA貢獻1877條經驗 獲得超1個贊
(select * from xxx where id = 1) union (select * from xxx where id = 2) union (select * from xxx where id = 4) union (select * from xxx where id = 3)
?
或加個sort字段

天涯盡頭無女友
TA貢獻1831條經驗 獲得超9個贊
@一個點的未來:?select id,contat(parent_id,id) seq from table order by seq
?
?
注意下?parent_id 為空的時候,聯合效果是:null 1 ?---- 1 ? 而不是 ? null1,如果搞不定,可以將null替換為""
添加回答
舉報
0/150
提交
取消