SELECT c.*
FROM customers c LEFT JOIN
     invoices i
     ON i.customer_id = c.id
WHERE i.customer_id IS NULL
The above works to give me all the customer accounts that have no invoices. It takes a long time to run, but I'm not concerned with the speed. I will likely only run this a couple times a year.
What I can't get right is updating a record in the customers table when the account has no invoices. I have tried a number of different ways to accomplish this but always get a syntax error.
One attempt is below...
UPDATE c
    SET active=0
    FROM customers c LEFT JOIN
         invoices i
         ON i.customer_id = c.id
    WHERE i.customer_id IS NULL
I get a syntax error in the Join when I try to run this.
 
     
     
    