Delete "Empty" Fields with no Data Reference

Hey everyone,

maybe someone can help me: I have a data base table two linked / referenced data fields on a second table. In this case the table should match "friends".
As soon as one of the friends is deleting his account there is the correct "Refernce no longer exists"-Statement.

Using Tasks I want to get rid of empty reference-fields over night. The question is: How do I make up the query?

I want to select all fields with "no reference" and then delete it by using a loop.

But i sadly cant find the correct query parameter for this field

Any ideas?