How can I know/ check a requested page/ row is a sub row or sub-sub row?
For instance, this is my page table,
pg_id pg_url pg_title parent_id
1 a a 1
2 b b 2
3 aa aa 1
4 aaa aaa 3
pg_id 3 is a sub page as its parent is pg_id 1, while pg_id 4 is a sub-sub page as its parent is pg_id 3
Here is my query how I get the info usually,
SELECT
p.pg_id,
p.pg_url,
p.parent_id
FROM root_pages AS p
WHERE p.pg_id = '4'
but it does not give info whether this requested is a sub or sub-sub page.
is any way to achieve this with a query?
I think you would want something like this:
If the grandparent page ID isn’t null, it’s a sub-sub page. If it is, but the parent page ID isn’t null, it’s a sub-page.