PDA

View Full Version : Importing MYSQL Column Data for VBCredits from other Database?


Toupsx
08-20-2008, 10:17 PM
Greetings, here's what my problem is:
I have just recently imported my board from SMF to VB with Implex, working great. Of course it couldn't take the credit information with it. In my SMF board the table Members (same as the table User in VB pretty much) had two columns called money and moneyBank going along with each member's row. Now in VB I installed the mod VBCredits which put in the columns credits and credits_saved corresponding to each user's row. What I want to do is take the data from the money row from my old forum and put it in the new credits row in my new forum.. and the same for moneyBank & credits_saved..

They are basically the same exact thing just different names.

I'm inexperienced with SQL queries or importing/exporting data with specific columns like this so if anyone could help that would be amazing.

Marco van Herwaarden
08-21-2008, 06:32 AM
If you have questions/problems with a modification or style, then please post in the thread (or support forum/board) about that modification/style. Best chance to receive a reply from either the author or another member using the same modification/style.

Toupsx
08-21-2008, 10:20 AM
If you have questions/problems with a modification or style, then please post in the thread (or support forum/board) about that modification/style. Best chance to receive a reply from either the author or another member using the same modification/style.

Its a mysql question.. not style or mod.. I asked in VBCredits' mod topic and he said post here/at vbulletin.com because he doesn't know how.. so.. yeah..

Marco van Herwaarden
08-21-2008, 11:08 AM
Well we don't have any knowledge of the database stucture used in these modifications, they are really the only ones that can give a correct answer.

Toupsx
08-21-2008, 02:40 PM
Well we don't have any knowledge of the database stucture used in these modifications, they are really the only ones that can give a correct answer.

Read my first post please.. not looking to import everything from them.. I'm looking for help to import two single columns into the User table from another database whos member table is basically the same thing.. really has nothing to do/no needed information for either of the modifications.. its the default Vbulletin database structure for the User table.. with just two columns that I want to import data to..

Regs
08-21-2008, 02:44 PM
I believe what he is asking is pretty straightforward in the sense that it doesn't matter which modification he is using.

The point being made is that both structures are the same just the 2 columns are names differently. On one side, the 2 columns has all the data and the other has none.

To the original poster, one avenue you might want to try is export the 2 tables using phpmyadmin, open them up in a spreadsheet and copy the data over from one file to the other. Then import back using phpmyadmin.

This is of course assuming that the userids in both tables match up, if not, you might need to do some 'massaging'.

I would test this out on a test install first.

There are probably much better ways of doing this but you'll need a helpful coder here to get you going.

Cheers,

Regs.

--------------- Added 1219333529 at 1219333529 ---------------

I should add that when I say copy the data over, I mean just the 2 columns, not everything :)

Toupsx
08-21-2008, 02:55 PM
I believe what he is asking is pretty straightforward in the sense that it doesn't matter which modification he is using.

The point being made is that both structures are the same just the 2 columns are names differently. On one side, the 2 columns has all the data and the other has none.

To the original poster, one avenue you might want to try is export the 2 tables using phpmyadmin, open them up in a spreadsheet and copy the data over from one file to the other. Then import back using phpmyadmin.

This is of course assuming that the userids in both tables match up, if not, you might need to do some 'massaging'.

I would test this out on a test install first.

There are probably much better ways of doing this but you'll need a helpful coder here to get you going.

Cheers,

Regs.

--------------- Added 1219333529 at 1219333529 ---------------

I should add that when I say copy the data over, I mean just the 2 columns, not everything :)

Hello, yes that basically sums it up, I tried exporting the data & then importing it selecting "just the columns I wanted" in the import.. didn't work, it completely erased the user (made it on a test user just importing those two columns for just it). So yeah. if someone could give me some better instructions on how to do it or a better way to do it, would be great.

Opserty
08-21-2008, 02:56 PM
If you have no experience with MySQL then you may want to consider hiring someone to do it for you. If there was an easy answer, someone would have given it by now. My best guess would be that you'd need to use an "UPDATE" possibly with a join (if thats possible in update queries).

Toupsx
08-21-2008, 03:28 PM
If you have no experience with MySQL then you may want to consider hiring someone to do it for you. If there was an easy answer, someone would have given it by now. My best guess would be that you'd need to use an "UPDATE" possibly with a join (if thats possible in update queries).

It really doesn't seem that hard of a thing.. you have 1 database with 2 columns with data in them.. you have another database with 2 columns with the exact same set up with no data in them... you take data from database 1 and put it in database 2.

That's all I want.. all these mod makers and such do a lot more & harder SQL things I'm sure so really don't think it would be worth spending money on.. seems like a 5 minute job for someone that actually knows how to do it.. really only want this to save me from putting in the data manually for each user..

Eikinskjaldi
08-22-2008, 02:41 AM
It really doesn't seem that hard of a thing.. you have 1 database with 2 columns with data in them.. you have another database with 2 columns with the exact same set up with no data in them... you take data from database 1 and put it in database 2.



assuming both databases are on the same system:


update vbdatabase.user u, otherdatabase.credittable o
set u.newfield1=o.oldfield1, u.newfield2=o.oldfield2
where u.userid=o.userid

Toupsx
08-22-2008, 10:08 AM
assuming both databases are on the same system:


update vbdatabase.user u, otherdatabase.credittable o
set u.newfield1=o.oldfield1, u.newfield2=o.oldfield2
where u.userid=o.userid


I'll try that out.. but how would it connect t the other database? wouldn't it need the host/DB name/user/password?

Dismounted
08-22-2008, 10:14 AM
If both databases are on the same server, and the user specified when connecting has permissions to both databases, that query will work.

Marco van Herwaarden
08-22-2008, 11:49 AM
"basically the same" is not "the same", hence why it is difficult to provide a solution based on your information. Like already mentioned: are both systems for example use the same userid? So is user "1" also user "1" in the other system. Can you match in some way the userid's between these systems?

A lot more info needed if you want an answer here.

Toupsx
08-22-2008, 03:12 PM
If both databases are on the same server, and the user specified when connecting has permissions to both databases, that query will work.

Don't believe they are, my webhost puts databases on different hosts & such.. one is on 1 host, another on a different host =\


"basically the same" is not "the same", hence why it is difficult to provide a solution based on your information. Like already mentioned: are both systems for example use the same userid? So is user "1" also user "1" in the other system. Can you match in some way the userid's between these systems?

A lot more info needed if you want an answer here.

Yes, all user info matches.. user id on 1 matches the other, username matches the other, etc.

Don't know what info is needed so just ask and I'll provide what I can :)

Marco van Herwaarden
08-24-2008, 08:45 AM
I find it very hard to believe that after importing from SMF to vBulletin with ImpEx, your vBulletin users have the same userid as the SMF userid. This is almost impossible.

Darkwaltz4
08-24-2008, 08:58 PM
Hmm, well I just finished taking care of this for Toupsx, but it seems everyone kind of misunderstood my initial suggestion to him..

As impex converts certain columns from the target database (in this case, SMF) into corresponding columns in vBulletin, I figured that somewhere in impex is the definition list for these columns. I just didn't know where to find it in order to add that the 'money' column in SMF user table goes to the 'credits' column in vBulletin's user table.

Thats all that was needed... I've never used impex or played around with it, so if anyone knows this offhand would be useful to know :p (all the files are NUMBERED which makes it that much harder to guess where to find the definitions). What we ended up doing was using a CSV file with the specific columns to create a series of update queries attached to the importuserid created by impex on the vbulletin user table (that much I knew).