On 5 Jul, 06:25, Salve Håkedal <no> wrote:
Seems to me that you have some redundant data here.
| is_answ | set to 'y' if the entry is an answer
| answ_to | set to the 'nr' of the entry that it is an answer to
If it is an answer, it will have a value in answ_to, otherwise it
Thus you do not need is_answ.
Likewise, if the nr value for a row exists in the answ_to column, the
entry has an answer.
Thus you do not need has_answ.
Take a look at the normalisation section of the mysql manual and tidy
up the table. The operations you wish to do will get eaasier.
For your actual problem, you would be better of storing your data as a
tree. The operations to remove branches are then clearly defined.