title: Comparing product statuses in Billing Software
body: <p>To simplify our lives at work, I wrote modules for our billing system allowing us to easily create "products" when we setup free Databases/DNS records and keep track of them in our billing software. Unfortunately, these are standalone entries rather than sub-entries of the paid products we include these services with.</p>
  
  <p>I have realized now that we have thousands of Databases/DNS Records still setup where the customer's have since cancelled their other paid services.</p>
  
  <p>I need to query each client's completely list of billing items and if they have either A) Database B) DNS Record C) Both and no other active services, terminate them.</p>
  
  <p>My question is just logistically speaking, how can I do this? Each Product has a unique ID but I am just drawing a blank on how to check with these conditions.</p>