Go Back   vb.org Archive > Community Discussions > Forum and Server Management
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2012, 10:26 PM
howarde's Avatar
howarde howarde is offline
 
Join Date: Sep 2007
Location: Florida
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 12-17-2012, 12:11 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 12-17-2012, 12:39 AM
howarde's Avatar
howarde howarde is offline
 
Join Date: Sep 2007
Location: Florida
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Thanks!
Reply With Quote
  #4  
Old 12-17-2012, 12:53 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #5  
Old 12-17-2012, 01:03 AM
howarde's Avatar
howarde howarde is offline
 
Join Date: Sep 2007
Location: Florida
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 12-17-2012, 01:13 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 12-17-2012, 01:22 AM
howarde's Avatar
howarde howarde is offline
 
Join Date: Sep 2007
Location: Florida
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #8  
Old 12-17-2012, 01:27 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 12-17-2012, 01:32 AM
ForceHSS ForceHSS is offline
 
Join Date: Apr 2008
Posts: 6,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could cause problems leaving that field blank. Have you checked for any plugins for bouncing emails I am sure there are some around
Reply With Quote
  #10  
Old 12-17-2012, 01:33 AM
howarde's Avatar
howarde howarde is offline
 
Join Date: Sep 2007
Location: Florida
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:33 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.04808 seconds
  • Memory Usage 2,251KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete