在MySQL执行以下层次结构查询时,即父对子关系
SELECT account_id
FROM
(
SELECT
account_id,
CASE WHEN account_id = 100016
THEN @idlist := CONCAT(account_id)
WHEN FIND_IN_SET(parent_id, @idlist)
THEN @idlist := CONCAT(@idlist, ',', account_id) END AS checkId
FROM account_master
ORDER BY account_id ASC
) AS T
WHERE checkId IS NOT NULL;
在第二次执行时获得不同的输出它可以得到正确的输出。
任何人都可以告诉我解决方案适用于上述书面查询以便在首次执行时获得正确的输出。