我的目标是找到层次结构中的最高位置。为了更好地解释,我在下面提供了视频。
这是我正在运行的当前查询:
SELECT * FROM 'agent_heirarchy' WHERE 'user_id'=370524; /
SELECT * FROM 'agent_heirarchy' WHERE 'id'= 24273; / this is the parent id of 370524
SELECT * FROM 'agent_heirarchy' WHERE 'id'= 301; / this is the parent id of 24273.
查询将在此处停止,因为 301 的父 ID 为空。 // 只有当父 id = Null 时才会停止
我目前正在做的事情的视频:https://streamable.com/51zxzi
所以我的最终目标是,有没有一种方法可以让我运行比目前更简单的查询?