vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help mysql query to change post/thread owner (https://vborg.vbsupport.ru/showthread.php?t=325806)

postcd 11-25-2017 09:21 AM

Help mysql query to change post/thread owner
 
Hello,

i have two users who posted topics where they mention phrasse: news.google.com

my aim is either delete such posts (but it seems to be too complicated as you can see there) or to change these topics/posts owner/user using mysql query.

Quote:

SELECT * FROM `post` WHERE `pagetext` LIKE '%news.google.com%'
it found 2 users which have matching posts:

username: username1, username2
userid: 479, 0
pagetext: %news.google.com%

(username2 had userid 308 before i wrongly removed his account, keeping his posts)

Quote:

SELECT * FROM `thread` WHERE `postusername` LIKE 'username1' AND `postuserid` LIKE '308' AND `replycount` LIKE '0' AND `notes` LIKE 'Imported thread'
This found posts i want to attribute to different user with id example: 308.

So as a total mysql noob, i tried:
Quote:

UPDATE `thread` SET `postuserid` = '308' WHERE `postusername` LIKE 'username2' AND `postuserid` LIKE '308' AND `replycount` LIKE '0' AND `notes` LIKE 'Imported thread'
but is wrong. Can you please help with right mysql query/ies to change user id of the topics/posts that contain phrasse news.google.com? Thank you

Dave 11-25-2017 01:14 PM

LIKE is used to check if a column contains a string, but your usage in the UPDATE query is wrong and I don't think that's what you really want to use anyway.

To match a value, you use =.
WHERE postusername = 'username2' AND postuserid = 308 AND replycount = 0 AND notes = 'Imported thread'.

Just keep in mind that you also need to update the userid in the post table. (First post of the thread)

Seven Skins 11-25-2017 02:14 PM

1 Attachment(s)
Don't know if this is what you are looking for.

Quote:

SELECT * FROM `post` WHERE `pagetext` LIKE '%news.google.com%' AND `userid` = 0;

update `post` SET `userid` = '308' WHERE `pagetext` LIKE '%news.google.com%' AND `userid` = 0

See attachments for the results.. both queries returned same number of results.



https://vborg.vbsupport.ru/attachmen...1&d=1511626364
https://vborg.vbsupport.ru/attachmen...1&d=1511626364


All times are GMT. The time now is 09:12 PM.

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.01001 seconds
  • Memory Usage 1,717KB
  • 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
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete