How to check for the same data/or compare the data in the database?

Hi Experts,

I have a situation where I need to check where the two different entities M & S have the same range. If they have the same range then I need to draw a diagram on the both M & S. If they do not match up then i need to just draw a diagram on M. How to check and search through the data in sql server?  Thanks
developer2012Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CodeCruiserConnect With a Mentor Commented:
Here is an example
Note that I used dummy names such as EntityName, EntityValue which you will need to replace with your actual column names.

Dim dbadp As New System.Data.SqlClient.SqlDataAdapter("Select * From tablename Where EntityName In ('M', 'S')", "Your connectionstring here")
Dim dTable As New System.Data.DataTable
dbadp.Fill(dTable)
dbadp.Dispose

if dTable.Rows.Count = 2 Then
   If dTable.Rows(0).Item("EntityValue") = dTable.Rows(1).Item("EntityValue") Then
      'Same value
   Else
      'Different value
   End If
End If

Open in new window

0
 
käµfm³d 👽Commented:
So two different rows in the database? Or are you trying to compare two tables?
0
 
developer2012Author Commented:
two different rows in the database.
0
 
developer2012Author Commented:
Two different rows
0
 
SharathData EngineerCommented:
Can you post some sample data with expected result?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.