Hello guys, sorry if you'll find this question stupid, but I really need help. Here's some info about it.
Database structure
id | parent_id | level | name
1 | 0 | 1 | Home page
2 | 1 | 2 | Child of homepage
3 | 1 | 2 | Another child of homepage
4 | 2 | 3 | Sub child of page id 2
5 | 3 | 3 | Sub child of page id 3
Question
How do I make the SQL statement to group my rows by level and make this output.
Desired output
Home page
~~Child of homepage
~~~~Sub child of page id 2
~~Another child of homepage
~~~~Sub child of page id 3
I know how to do this with a recursion method, but I want to know if I can accomplish this with one SQL statement. Thanks.