Back to General Articles

[vB3/vB4] VERY general SQL query via AdminCP to change usernames in quotes.
by Max Taxable 25 Jun 2014

You gave someone a username change. Great, but his old username is still in all places where he was quoted in the past.

Run this query in AdminCP, replacing with actual usernames
HTML Code:
UPDATE post SET pagetext = REPLACE(pagetext, '=old name', '=new name')


BUT: if there exists a apostrophe in the old username, the DB will think that's the end of the string and will kick a syntax error. Therefore where apostrophe exists in either username, double it, as such: ''

Example:
HTML Code:
UPDATE post SET pagetext = REPLACE(pagetext, '=Sammy''s', '=Elliot')
Where old name was: Sammy's and new name is: Elliot.

You're welcome.

vblts.ru supports vBulletin®, 2022-2024