my target is to find the highest position in hierarchy. I have provided video below for better explanation.
This is the current query I am running:
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.
The query will stop here because the parent id of 301 is null. // It will only stop when the parent id is = Null
Video of what I'm currently doing: https://streamable.com/51zxzi
So my final target is, is there a way where i can run a much easier query than what i'm currently doing?