I have a self-referencing table 'comments' where comments.replyToId REFERENCES comments.ID.
My question is, how do I query a database with a self-referencing table to get a result that is properly ordered so that I can represent the result as a tree in PHP?
I've tried
select * from comments as comments_1
left join comments as comments_2
on comments_1.id = comments_2.replyToId
I'm trying to use the result of this in php