News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Need SQL statement

Started by castle900, December 20, 2005, 12:17:51 PM

Previous topic - Next topic

castle900

To pull M_NAME from my old Snitz mysql database table forum_members and import it into the new SMF database memberName in the member table .  I have phpMyAdmin but just don't know the statement I would use to do it. Thank You in advance

Oldiesmann

INSERT INTO forum_members (memberName) SELECT M_NAME FROM {snitz_table};

Replace {snitz_table} with the name of the appropriate table in the Snitz database. Also, if you only want to import certain ones, make sure you add a "WHERE M_NAME = 'x'" or "WHERE M_NAME IN ('x', 'y', 'z', ...)" in that query.
Michael Eshom
Christian Metal Fans

castle900

Well that worked.. just not quite how i wanted it to. It created new rows in the member table. Any way I can make it so it doesn't make new rows? I just want it to add to what is already there.

Oldiesmann

Yes. As long as you've got something that will be the same in both tables...

<?php
include_once('SSI.php');
$query1 db_query("SELECT M_NAME, {emailcolumn} FROM {snitztable}"__FILE____LINE__);
while(
$results mysql_fetch_row($query1))
{
    
$query2 db_query("UPDATE {$db_prefix}members SET memberName = '$results[0]' WHERE emailAddress = '$results[1]'"__FILE____LINE__);
}
?>


Replace {emailcolumn} with the name of the email field in Snitz's members table and {snitztable} with the name of the Snitz members table.

You can then run this query to delete all the rows you just inserted:

DELETE FROM smf_members WHERE emailAddress = '';
Michael Eshom
Christian Metal Fans

castle900

I got it.. After snooping around mysql docs and the convert script I did
UPDATE lee_smf.smf_members SET memberName = realName;

That worked like a charm. I looked into the convert sql script and it set the M_NAME to realName when it should also set M_NAME to memberName All my users didn't have a username to log into. It was set to their display name. Thanks for all your help. Its greatly appreciated  :)

Advertisement: