행위

Mysql 계층쿼리

DB CAFE

mysql 계층쿼리

SELECT @r as id, ( 
SELECT @r := parent_id FROM h_test WHERE id = @r 
) AS _PARENT_ID, @l := @l + 1 AS lv 
FROM ( 
SELECT @r := 5 
) _id, h_test h 
WHERE @r <> 0