Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare 2 different tables columns from 2 different databases

I have a requirement to compare different tables' columns from 2 different databases, in order to add columns to the master tables based on the requirement.

For example:

Assume in master database I have created one table like:

create table test(id int,name varchar(10))

Assume in test database I have created one table like

create table testings(id int,name varchar(20), sal int)

now I have to compare 2 table columns

I don't want to use red-gate tools.

Can anyone help me?

like image 926
Franklin Avatar asked Nov 22 '12 10:11

Franklin


People also ask

How do I compare two columns in different databases?

Here's the generic SQL query to two compare columns (column1, column2) in a table (table1). mysql> select * from table1 where column1 not in (select column2 from table1); In the above query, update table1, column1 and column2 as per your requirement.

How can I compare two tables in different columns in SQL?

We can use union to compare the columns once we can have the union of both the tables. It can quickly check what are the data missing or changed in either table. It is capable of handling null values which cannot be handled by where clause. This is only used when we have the same type of tables.


1 Answers

Is it just red-gate tools you don’t want to use or basically any third party tool? Why not, even if you don’t have the budget to buy you can still use this in trial mode to get the job done?

We’ve been using Apex Diff tool but there are many more out there.

With so many tools available you can probably run all one by one in trial mode for months…

Knowing system tables and how to do this natively is great but it’s just too time consuming...

like image 94
Phill C Avatar answered Oct 06 '22 21:10

Phill C