Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-15-2012, 04:23 AM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Moving users into a user group based on signature url and ...

Ok so I'm trying to move users from the registered user group into another user group if they have a certain url in their signature, have zero posts, and a certain lastvisit time.

This is the query I came up with;
Code:
UPDATE user SET usergroupid = 3
WHERE (SELECT userid 
        FROM usertextfield
        WHERE signature LIKE 'google')
AND posts = 0
AND lastvisit = 1342328885
The attached picture is what happens in phpmyadmin.

No users get moved Yes I have one user with the signature of www.google.com with zero posts and a lastvisit of 1341119285. Doesn't do anything different if I replace = with another symbol ( < > <= >= ) in the lastvisit clause.
Attached Images
File Type: jpg what_the.jpg (90.4 KB, 0 views)
Reply With Quote
  #2  
Old 09-15-2012, 01:33 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have to be honest and say that I don't fully understand your query, with a SELECT in there like that, so it that may be OK. But I think you want to use LIKE '%google%'. In any case, I probably would have done this:

Code:
UPDATE user LEFT JOIN usertextfield ON (user.userid = usertextfield.userid)
SET usergroupid = 3
WHERE signature LIKE '%google%'
AND posts = 0
AND lastvisit = 1342328885
Reply With Quote
  #3  
Old 09-15-2012, 08:40 PM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got that select bit from reading over at stackoverflow, was pretty sure it wouldn't work but it didn't spit out an error either

Your suggestion did not work either I had tried using a JOIN (left and right) and neither worked, which is why I had nothing to lose by trying the query I posted
Reply With Quote
  #4  
Old 09-15-2012, 10:03 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try this?
Code:
UPDATE user SET usergroupid = 3
WHERE (SELECT userid 
        FROM usertextfield
        WHERE signature LIKE '%google%')
AND posts = 0
AND lastvisit = 1342328885
Reply With Quote
  #5  
Old 09-15-2012, 10:16 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by John Lester View Post
I got that select bit from reading over at stackoverflow, was pretty sure it wouldn't work but it didn't spit out an error either
What I was trying to say above (except that I messed up that sentence and it doesn't make any sense) is that it may well be correct, I just don't know.


Quote:
Your suggestion did not work either I had tried using a JOIN (left and right) and neither worked, which is why I had nothing to lose by trying the query I posted
Hmm...I tested mine before posting it and it seemed to work. I adjusted the WHERE stuff so that it would match one of my test users, but I don't think that should have made any difference.
Reply With Quote
  #6  
Old 09-16-2012, 12:17 AM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Scanu View Post
Did you try this?
<snip>
Hi I did indeed, the query executed successfully, but the users user group wasn't changed.

It might be an issue with the user, I'll have to adjust the lastactive time and see if that works.

--------------- Added [DATE]1347775503[/DATE] at [TIME]1347775503[/TIME] ---------------

So I decided I could live without using lastvisit since I'm already checking signature url and post count.

Code:
UPDATE user LEFT JOIN usertextfield ON (user.userid = usertextfield.userid)
SET usergroupid = 3
WHERE signature LIKE '%google%'
AND posts = 0
Funny enough, if I use the code I posted first and leave off the lastvisit time, it moves all users with zero posts regardless of what's in their signature. *shrug* I would love to go to school and learn the bass ackwards logic the codes seems to like
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 04:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03722 seconds
  • Memory Usage 2,233KB
  • Queries Executed 12 (?)
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
  • (4)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (1)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete