• Resolved JudahsMom63

    (@judahsmom63)


    I have two databases on the same server – let’s call them DBA and DBB. DBA is being used by SiteA and DBB isn’t being used by any website. However, DBA is version 2 of DBB, and DBA is missing data that DBB has. The tables in DBA and DBB have the same table names, aka Table1, Table2, and Table3. I want to join the tables on DBA with the tables on DBB so that DBA has all the data necessary for SiteA. What’s the best way to accomplish this? I’ve checked the forum but haven’t found any answers newer than six years ago.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theres no real way to “join” tables like that, at least not using the standard WordPress functions.

    The big question is… does DBB in your example have all of the data for the site, or is there different data in both DB’s?

    If DBB holds everything, then just switch over to using that database, and forget about DBA.

    If DBB and DBA are different, you’d have to look at exactly which tables contain different data. If you’re trying to move things like posts or pages across, thats possible, but you’d need to do a bit of work in the export and import process to make sure that all of the ID’s are consistent when you copy everything from the meta tables as well.

    Thread Starter JudahsMom63

    (@judahsmom63)

    catacaustic – thanks for replying. I apologize in advance for the upcoming long story, but it explains a lot.

    I made a website for a guy who, after delivery, managed to mess up the website with lots of help from his half-rate hosting site. He gave it back to me, and in my research I discovered that the database I gave him, DBA, had data removed from three tables crucial to the operation of a plugin. (The tables are there, but not the data.) Fortunately for him, I have a backup of his database (DBB). I need to get the data from the three tables in DBB to DBA. DBA has tables that DBB does not have, so switching databases is not an option. The thought of having to manually enter all of that data into DBA (bleeps) me off. That’s why I thought of using a join. It’s been a while since I’ve worked with SQL. Is there any way, short of sitting and typing for hours that I can transfer this data?

    Thread Starter JudahsMom63

    (@judahsmom63)

    Here’s what I’m trying to fix: http://www.picklestreetcreations.com/test_sandbox/

    If it’s three tables only that have been removed you can safely create an SQL dump from the “correct” database and import them into the other database. Any DB management tool will be able to do that, with the most common being phpMyAdmin.

    Thread Starter JudahsMom63

    (@judahsmom63)

    catacaustic – you are indeed very awesome! Your solution worked perfectly. Thanks for helping me, I really appreciate it!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘join tables from 2 sql db's on one server’ is closed to new replies.