I have a table named ‘posts’. It is in a structure like this:
post_id, post_content, post_parent
The post parent is an int is used to signify if a post is a parent. If it is equal to 0, it is a parent. If it isn’t equal to 0, the post_parent is relative to the post_id that is the parent post.
I want a way that I can select the posts in MySQL so that is weighs the posts and orders them according to their parents.
The results should be like this:
- Post Parent
- Post Parent
- Child Posts with a post_parent relative to the above Parent Post’s post_id
- Child Posts with a post_parent relative to the above Parent Post’s post_id
- Post Parent
Thank you in advance!
I have no idea what the table looks like so i am making this up as I go along.
This should get you all parents with their children: