这是我正在使用的查询,但仅提供id = 33
SELECT id, name ,parent_store_id, store_level FROM
(SELECT id, name ,parent_store_id, store_level,
CASE WHEN id = 33 THEN @idlist := CONCAT(id)
WHEN FIND_IN_SET(parent_store_id,@idlist) THEN @idlist := CONCAT(@idlist,',',id)
END as checkId
FROM cx_store
ORDER BY id ASC) as T
WHERE checkId IS NOT NULL