Dmitrij Holkin
Dmitrij Holkin

Reputation: 2055

Align two mysql tables

I have two databases. WordpressDB and JoomlaDB

WordpressDB has table db1_users JoomlaDB has table db2_users

thoose tables has the same fields names

id  | email | Login | Password

General database is WordpressDB. So i need all id in JoomlaDB make the same as id in WordpressDB where email field is the same.

So how to do that, it is about 10.000 entries?

Upvotes: 3

Views: 353

Answers (2)

Rifai
Rifai

Reputation: 194

I don't know if this is right or not, but if you're looking for query to update ID in table joomla using data ID in table wordpress, I think you can use this :

update WordpressDB.tbl_user1 
set WordpressDB.tbl_user1.ID=(
select JoomlaDB.tbl_user2.ID from JoomlaDB.tbl_user2 
where JoomlaDB.tbl_user2.EMAIL=WordpressDB.tbl_user1.EMAIL
) 

Upvotes: 1

KAD
KAD

Reputation: 11122

You can create a column wp_user_id in the table db2_users and create a migration script to map the user ids from WordpressDB db1_users to JoomlaDB where same mail exists.

In this way you wont affect how Joomla handles user ids and you can achieve your needs.

Just note that you may fall a victim of concurrent update since tow modules might update the same row at the same time, in this case you might need a locking mechanism when updating user rows on JoomlaDB.

Upvotes: 1

Related Questions