Page 1 of 1

Compare specific field from two different database table

Posted: Wed Jan 06, 2016 9:37 pm
by KraZy
I'm actually developing a synchronization tool in vb.net, I have two database that have on each table records field GUID, this field help to have the same PK on both database. On each record there is also a field called lastUpdated, this field have a milliseconds value, so prevent two user to update the record in the same time. My question is, how I can compare the records of the same table from different db? For example:

ONLINE_DATABASE

TABLE_1
Code: Select all
| ID |   GUID                             | NAME  |    LASTUPDATED              |
| 5  | 054ba092-b476-47ed-810b-32868cc95fb| John  | 06-01-2016 17:01:12.472438  |
CLIENT_DATABASE

TABLE_1
Code: Select all
| ID |   GUID                             | NAME  |    LASTUPDATED              |
| 9  | 054ba092-b476-47ed-810b-32868cc95fb| Jack  | 06-01-2016 18:01:12.472438  |
How you can see I've update the record from client application, so I need to apply the same change to online database. Now I've a thousand records to check in about ten tables. So my question is, how I can made a system that do this? Actually I tough to read each row with a MySqlCommand reader but I also think that this procedure is slow... Suggest?

NOTICE THAT: the table have the same name in both db

Re: Compare specific field from two different database table

Posted: Wed Jan 06, 2016 9:40 pm
by visualtech
I'd suggest you use relational mappings for your tables. Then, you can setup by-pass connecters for the different databases you have, and voila! If you need help, you know where to find me! :D

Re: Compare specific field from two different database table

Posted: Wed Jan 06, 2016 9:58 pm
by KraZy
relational mapping? I don't know what is this, could you help me?

Re: Compare specific field from two different database table

Posted: Wed Jan 06, 2016 10:02 pm
by visualtech
Skype. @chris.harrison367

Re: Compare specific field from two different database table

Posted: Wed Jan 06, 2016 10:14 pm
by KraZy
Again, I doesn't have skype account more, you have another social like hangouts or other?

Re: Compare specific field from two different database table

Posted: Wed Jan 06, 2016 10:19 pm
by visualtech

Re: Compare specific field from two different database table

Posted: Thu Jan 07, 2016 8:46 am
by KraZy
visualtech wrote:
labs.visual@gmail.com - Hangouts
I contacted you, hope that you can help.. I'm Ferven

Re: Compare specific field from two different database table

Posted: Thu Jan 07, 2016 11:34 am
by visualtech
For what you've mentioned a simple query like the following should do; tweak it as you like:
Code: Select all

SELECT 
	CLIENT_DATABASE.TABLE_1.*,
	ONLINE_DATABASE.TABLE_1.*
FROM
   CLIENT_DATABASE.TABLE_1
       INNER JOIN ONLINE_DATABASE.TABLE_1
           ON CLIENT_DATABASE.TABLE_1.GUID = ONLINE_DATABASE.TABLE_1.GUID