#Delete private lists without owner that now have no shares anymore $query="DELETE vs.* FROM virtualshelves vs LEFT JOIN virtualshelfshares sh USING (shelfnumber) WHERE category=1 AND vs.owner IS NULL AND sh.shelfnumber IS NULL"; $dbh->do($query); #Change owner for private lists which have shares $query="UPDATE virtualshelves LEFT JOIN virtualshelfshares sh USING (shelfnumber) SET owner=NULL where owner=? AND category=1 AND sh.borrowernumber IS NOT NULL"; $dbh->do($query,undef,($borrower)); #Handle public lists owned by borrower $query="UPDATE virtualshelves SET owner=NULL WHERE owner=? AND category=2"; $dbh->do($query,undef,($borrower)); #Niet nodig vanwege table constraint.. $query="UPDATE virtualshelfcontents SET borrowernumber=NULL WHERE borrowernumber=?"; $dbh->do($query,undef,($borrower));