Submitting, please wait...
let today = new Beginning();
Click the left button to use the catalog.
查询是否存在父Id和该表其他Id一致的数据: SELECT * FROM Comments A WHERE EXISTS(SELECT * FROM Comments B WHERE A.`ParentId`=B.`Id`) 这一条可以查询出来到底还要多少条合法子数据。 非法子数据直接加NOT会把父Id=0也筛选出来: SELECT * FROM Comments A WHERE NOT EXISTS(SELECT * FROM Comments B WHERE A.`ParentId`=B.`Id` ) 所以应该再加一句AND ParentId!=0: SELECT * FROM Comments A WHERE NOT EXISTS(SELECT * FROM Comments B WHERE A.`ParentId`=B.`Id`) AND ParentId!=0 但是最后删除的话,用这句其实是不行 ...
2022-03-04 13:04:47
1k+ 1580 reads
1 comments