NodsDorf Posted May 9, 2009 Posted May 9, 2009 So getting to the 20,000 customer mark and need to get rid of those customers who haven't ever bought anything. Biggest issue is Quickbooks only allows 14,500 customers without shelling out major cash for Enterprise edition. That said I wrote this query Select * from customers Where not exists (select * from orders where customers.customers_id=orders.customers_id) Order By customers_id This query works, it fetches all customers who do not have an entry in the orders table. So I figured just change the Select to Delete drop the order by and all is well... but I am getting this error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* from customers Where not exists (select * from orders where customers.custome' at line 1 Anybody have any advise? Thank you
NodsDorf Posted May 9, 2009 Author Posted May 9, 2009 Thank you, found the issue DO NOT RUN THIS WILLY NILLY BACKUP FIRST! Correct code to delete all customers who never bought anything is: DELETE FROM customers WHERE NOT EXISTS ( SELECT * FROM orders WHERE customers.customers_id = orders.customers_id ) Needed to remove the *
Recommended Posts
Archived
This topic is now archived and is closed to further replies.