blah blah blah is here! blah blah » Close

up0down
link

I need to compare two database tables t1 and t2 column by column here is my idea about that :

For (int i= 0 ;i<= number of column in t1;i++)
{
Read columni
For (int j= 0 ;j<= number of column in t2;i++)
{
Read columnj
If (columni name from t1= columnj name from t2 )
{
[] Array1 = (select distinct(columni) from t1)
[] array2= (select distinct(columnj)from t2)


// make some operation on array1 and array2

}
}

Pls help

last answered one month ago

1 answers

up0down
link

If you are using database tables, your best approach would involve using SQL to get the differences because it is better designed for the purpose. e.g.

(select * from A
minus
select * from B) -- Rows in A that are not in B
union all
(
select * from B
minus
select * from A
) -- rows in B that are not in A

it probably isn't the most efficient because this is off the top of my head but it's a start

Feedback