I have a query that works but it is really slow. Please let me know if there is a better way to do this so that it is quicker. Below is the query:
delete NOBAL.* from ar__b23ccd as NoBAL inner join (select ptid from ar__b23ccd group by ptid having sum(balance)=0) as temp on temp.ptid =...
if i change your version by addin 'in' like this
delete
from ar__b23ccd
where ptid
in( select ptid
from ar__b23ccd
group
by ptid
having sum(balance) = 0.00 )
Then i get the following error:
You can't specify target table 'ar__b23ccd' for...
I get the error below
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 'select ptid from ar__b23ccd group by ptid having sum(balance) = 0.00 )' at line 1
That is a good question and I think for the moment we will say that i want to delete all records from the table that have a sum of zero. If you can help shed some light on this it would be most helpfull.
Thanks
I need some help with this query. I have a table that contains purchase records. This table we can call "Purchases". Within this table I have a column called "ptid" which is related to the client info and there can be multiple records with the same "ptid". There is also a "balance" column. What...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.