--- a/admin/linkAmendments.php +++ b/admin/linkAmendments.php @@ -25,6 +25,16 @@ else print_r($errors); } -// also need to eliminate CN 100528/100529 - check for double parent CNs with no childCN, latest sequent CN id wins childCN = 0 +// also need to eliminate CN 100528/100529 - check for double parent CNs with no childCN, latest sequent CN id keeps childCN = 0 +$query = 'SELECT "parentCN", array_agg("CNID"), count(*) from contractnotice WHERE "parentCN" IN +( + SELECT "parentCN" + FROM contractnotice + GROUP BY "parentCN" + HAVING COUNT(*) > 1 + AND "parentCN" != 0 +) +AND "childCN" = 0 +GROUP BY "parentCN" having count(*) > 1'; ?>