Skip to content

Instantly share code, notes, and snippets.

@micw
Last active September 15, 2016 09:18
Show Gist options
  • Select an option

  • Save micw/1de4100c66b9d37d9c7df4a9fb55474b to your computer and use it in GitHub Desktop.

Select an option

Save micw/1de4100c66b9d37d9c7df4a9fb55474b to your computer and use it in GitHub Desktop.
SQL statement to update customer's email usage after manual changes
update panel_customers set
email_accounts_used=(select count(*) from mail_users where mail_users.customerid=panel_customers.customerid),
emails_used=(select count(*) from mail_virtual where mail_virtual.customerid=panel_customers.customerid),
email_quota_used=(select sum(quota) from mail_users where mail_users.customerid=panel_customers.customerid),
email_forwarders_used=(select sum(CHAR_LENGTH(replace(destination,email_full,''))-CHAR_LENGTH(replace(replace(destination,email_full,''),'@',''))) from mail_virtual where mail_virtual.customerid=panel_customers.customerid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment