簡單3個方面:數據結構
1.數據結構設計函數
2.快速查詢上面第幾級spa
3.快速查詢下級第幾級設計
快速查詢上級:code
SELECT * FROM oasis.oasis_user_info where id=(SELECT SPLIT_STR('1^.8^.9^.10', '^.',3) AS user_id)
快速查詢下級blog
SELECT * FROM oasis_user_info WHERE layer_tree LIKE '1^.8^%' AND bind_level = 2
SPLIT_STR函數class
CREATE FUNCTION SPLIT_STR( x TEXT,#這裏改類型(varchar|char) delim VARCHAR(12), pos INT ) RETURNS VARCHAR(255) RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos), LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1), delim, '');