I
I
im_dimas2019-06-18 21:22:04
SQL
im_dimas, 2019-06-18 21:22:04

How to organize a selection of comments from a table?

There is a table, it stores comments to articles,

id Первичный
project
date
autor
text
answer

answer - equal to zero if this is a comment - not a response to some comment, otherwise it stores the id of the comment to which it was answered
How to correctly pull out a list of comments with one request to a specific article?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Sviridov, 2019-06-18
@dimas199862

If the depth of comments is limited, then you can join the table with itself as many times as you need. If not, you can pull out all the comments of a particular article (there will hardly be too many of them) with one request - and build a tree already in php / python (well, or on what you wrote the backend).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question