vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Forum and Server Management (https://vborg.vbsupport.ru/forumdisplay.php?f=232)
-   -   Need help writing an SQL query to remove bounced emails (https://vborg.vbsupport.ru/showthread.php?t=293047)

howarde 12-16-2012 09:26 PM

Need help writing an SQL query to remove bounced emails
 
Hi,

I have a list of bounced emails, and I want to change the receive admin email option to "no" for these users, by running an update query on the user table.

I understand, I can change those options with this part:

UPDATE user SET options = options - 16 WHERE options & 16 AND userid = xxxx

However... I'm having a hard time coming up with the query to cross-reference the bounced email list. I figure I can import the bounced emails to a table called, "bounce" and essentially, I want to

UPDATE user (like above)

WHERE bounce.email = user.email

however... it's not that easy (for me) - maybe there's some mysql experts that could point me in the right direction?

kh99 12-16-2012 11:11 PM

Maybe something like this:

Code:

UPDATE bounce LEFT JOIN user USING (email)
  SET options = options - 16 WHERE options & 16


Maybe you could even add a column to your bounce table and set it so you know which ones matched.

howarde 12-16-2012 11:39 PM

Cool... It works, except I want to update "user" and LEFT JOIN bounce

Thanks!

kh99 12-16-2012 11:53 PM

I'm not a MySQL expert, but I think if you "left join bounce" you get a table with every user, but the columns from bounce will be blank unless there's a matching email. So you'd be resetting the options of every user (I think).

howarde 12-17-2012 12:03 AM

Actually, as I investigate further... this isn't what I want to do anyway. Changing the Admin Emails to "no" doesn't do what I want...

Basically, I have a list of all of the bounces from our database - there's a lot as we have more than 200,000 users in our database.

I want to set it so that bounces don't get subscription notifications or other emails at all anymore, as there are thousands of bounces weekly. Not sure what to do here.

kh99 12-17-2012 12:13 AM

Yeah, what you need to do is delete all the records with the matching userids from the tables subscribethread, subscribeforum, subscribeevent, subscribegroup, and subscribediscussion. But one issue is that if someone's email bounces temporarily or if they just didn't get around to updating their new email or something, doing that will erase all their subscriptions.

howarde 12-17-2012 12:22 AM

Hmm... sounds even more difficult.

What if I just remove their email addresses from the database, and limit the actions to users who have no activity in over 2 years (or something like that).

kh99 12-17-2012 12:27 AM

Yeah, removing the email is an interesting idea. If it's bad it doesn't matter, and a user can always just re-enter it. I don't know what else might happen if you just deleted the value from that field, but you could try it.

ForceHSS 12-17-2012 12:32 AM

Could cause problems leaving that field blank. Have you checked for any plugins for bouncing emails I am sure there are some around

howarde 12-17-2012 12:33 AM

Code:

UPDATE user LEFT JOIN bounce USING (email)
  SET user.email = ''
  WHERE bounce.email <> '';

I just ran this on a test database and it does remove the bounce emails from the user table, and leave the field blank.

Thanks for the help.

Quote:

Could cause problems leaving that field blank. Have you checked for any plugins for bouncing emails I am sure there are some around
I'll wait a few days to see if anyone has any real evidence of issues with blank emails in the DB.

Thanks.


All times are GMT. The time now is 06:38 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01774 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete