Reputation: 15
I want to know if that possible to compare two columns in two different tables in one database using C# with SQLSE. if the two table has the same data in order, i can say the two tables are match; otherwise, there is no match.
// More info
I want to compare two column has repeated value the two column vlaues come from actual combination of visits for two patients and i want to check do they visit the hospital on the same date and rational insted to go for every 5 combination and compare the match i want to compare the whole table
Upvotes: 0
Views: 290
Reputation: 583
As far as i understood (otherwise please add more information):
SELECT ColumnA, ColumnB, ColumnC FROM Table1 WHERE ColumnC IN (SELECT ColumnC FROM Table2)
Upvotes: 1
Reputation: 35605
Assuming you want to compare the data in the primary key columns of two tables; you could do something like the following and if CNT is greater than 1 then they do not match:
SELECT COUNT(*) CNT
FROM
X
FULL OUTER JOIN Y
ON
X.primaryKeyColumn = Y.primaryKeyColumn
WHERE
X.otherColumn IS NULL
OR
Y.otherColumn IS NULL
Your question is a little vague. You seem to be concerned about ORDER
. Do you consider the following two columns matching or not?:
Upvotes: 0