Home > database >  Sqlite3, please write a SQL statement to deal with a problem?
Sqlite3, please write a SQL statement to deal with a problem?

Time:09-28

Sqlite3 below id is the only table data structure pid is the parent id is the modify state 1 is to delete
I now is to delete data. I want to be an id when I want to have it the following child elements are deleted
The table below you can see
Id for the 2 child elements have 3, 4
Id for four child elements have 5 or 6
Id is 6 there are 7
child elementSo when I want to delete 2 (when the modify==1) I want to delete all child elements below it is 3 to 7 are deleted
Could you tell me how to write the SQL statement?????

Id pid modify
1 0 0
2 0 1
3 2 0
4 2 0
5 4 0
6 4 0
7 6 0

CodePudding user response:

The top...

CodePudding user response:

Using recursive code in the outside,

Sqlite does not support the stored procedure, the processing of complex