Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: efil59 on December 22, 2007, 01:15:31 PM

Title: Merge 2 Users
Post by: efil59 on December 22, 2007, 01:15:31 PM
Hi,
Is there a way to Merge 2 Users. ( i have the same member with 2 accounts).


Title: Re: Merge 2 Users
Post by: greyknight17 on December 22, 2007, 06:00:11 PM
It depends what you mean by merge here. Do you want to just merge the posts/topics for these two accounts? If so, you can update the database table so that all the messages from one of the accounts is renamed to reflect the other username.

Go into phpMyAdmin (http://www.simplemachines.org/community/index.php?topic=21919.0) and click on your database. Then click on the SQL tab and copy paste the following code and run it:

UPDATE smf_messages SET ID_MEMBER='THEIR_NEW_ID' WHERE postername='OLD_USERNAME';

Replace the smf_ prefix if you are using a different one for your database. Replace THEIR_NEW_ID with the member ID you want to have the combined posts. Replace OLD_USERNAME with the username you want the posts to be copied from.
Title: Re: Merge 2 Users
Post by: Tony Reid on December 22, 2007, 06:06:43 PM
Dont forget PM's
Title: Re: Merge 2 Users
Post by: efil59 on December 23, 2007, 02:03:44 AM
Quote from: greyknight17 on December 22, 2007, 06:00:11 PM
It depends what you mean by merge here. Do you want to just merge the posts/topics for these two accounts? If so, you can update the database table so that all the messages from one of the accounts is renamed to reflect the other username.

Go into phpMyAdmin (http://www.simplemachines.org/community/index.php?topic=21919.0) and click on your database. Then click on the SQL tab and copy paste the following code and run it:

UPDATE smf_messages SET ID_MEMBER='THEIR_NEW_ID' WHERE postername='OLD_USERNAME';

Replace the smf_ prefix if you are using a different one for your database. Replace THEIR_NEW_ID with the member ID you want to have the combined posts. Replace OLD_USERNAME with the username you want the posts to be copied from.

Hi,
Yes that what i meant, but it doesn't work for me.

here is the SQL query:
UPDATE smf_messages SET ID_MEMBER='214' WHERE postername='ערן';

And i get this.
שגיאה

שאילתת SQL:

UPDATE smf_messages SET ID_MEMBER = '214' WHERE postername = 'ערן'

MySQL אמר: תיעוד
#1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_unicode_ci,COERCIBLE) for operation '='


It's because the USERNAME is in hebrew.

Is there another way?


Title: Re: Merge 2 Users
Post by: metallica48423 on December 25, 2007, 07:13:25 PM
sounds like your database table is in one collation but the columns are

I'm not sure how to fix it though... i've never had this particular problem :(
Title: Re: Merge 2 Users
Post by: efil59 on December 29, 2007, 12:27:36 PM
Thank you anyway!

I did managed, i found the name of the user in the  character that the database use, and did the SQL query.
Title: Re: Merge 2 Users
Post by: greyknight17 on December 29, 2007, 01:36:48 PM
There are some of the tables that needs to be updated as well if you want them. One of them is the PMs as indicated by Tony. If that's ok to leave out, then you should be set.
Title: Re: Merge 2 Users
Post by: warhonowicz on April 01, 2008, 05:41:09 AM
what are the tables that need to be updated ... one of my users had issue logging in and created a new ID for himself and I would like to merge the two into one ... including everything, posts, pms etc
Title: Re: Merge 2 Users
Post by: Orange789 on April 04, 2008, 12:06:43 PM
I am not too good at SQL, but could you not just use the code:



UPDATE smf_messages SET ID_MEMBER='NEW ID' WHERE ID_MEMBER=OLD ID';

Then

UPDATE smf_personal_messages SET ID_MEMBER_FROM='NEW ID' WHERE ID_MEMBER-FROM='OLD ID';

then

UPDATE smf_personal_messages SET ID_MEMBER_FROM='NEW MEMBER NAME' WHERE ID_MEMBER-FROM='OLD MEMBER NAME';

then

UPDATE smf_pm_recipients SET ID_MEMBER_FROM='NEW ID' WHERE ID_MEMBER-FROM='OLD ID';


WARNING: Please don't action this until someone who actually knows can comment !


As I said, I dont really know SQL but just taking a logical approach to what I have read previously



Title: Re: Merge 2 Users
Post by: Informatics on April 04, 2008, 12:49:27 PM
Assuming that first ID is 1 and the second is 2. And we are want to merge 2 to 1.

1. Updating the ID poster to all messages

UPDATE smf_messages SET ID_MEMBER=1 WHERE ID_MEMBER=2

2. Updating Personal Messages

UPDATE smf_personal_messages SET ID_MEMBER_FROM=1 WHERE ID_MEMBER_FROM=2

3. Updating Personal Messages Recipients

UPDATE smf_pm_recipients SET ID_MEMBER=1 WHERE ID_MEMBER=2

4. Polling

UPDATE smf_polls SET ID_MEMBER=1 WHERE ID_MEMBER=2

5. Themes

UPDATE smf_themes SET ID_MEMBER=1 WHERE ID_MEMBER=2

6. Topics

UPDATE smf_topics SET ID_MEMBER_STARTED=1 WHERE ID_MEMBER_STARTED=2
UPDATE smf_topics SET ID_MEMBER_UPDATED=1 WHERE ID_MEMBER_UPDATED=2


If you wondering about this, dont do it...
Title: Re: Merge 2 Users
Post by: Orange789 on April 04, 2008, 12:59:01 PM
Oh,

I werent too far off and my logical thinking was "kinda" right :D
Title: Re: Merge 2 Users
Post by: warhonowicz on April 04, 2008, 03:08:53 PM
Thanks ... that got me a long way
Title: Re: Merge 2 Users
Post by: metallica48423 on April 05, 2008, 01:55:51 AM
sql is certainly strange to get a grip around :)

glad it worked for you guys :)
Title: Re: Merge 2 Users
Post by: warhonowicz on April 06, 2008, 09:06:07 AM
I find SQL very logical, it's like another language and you have to learn the vocab ... slowly getting there though