Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to compare 3 columns from 2 tables

Author  Topic 

mohan123
Constraint Violating Yak Guru

252 Posts

Posted - 2013-07-26 : 02:25:53
Hi all,
i have requirement like this
1 st column 'A1Ctest' 2 nd column 'diagnoising heart disease' and my 3 rd column is combination of both columns
'A1Ctest for diagnoising heart disease'.Here i need to comapre 'A1Ctest' from 1st column and 'diagnoising heart disease' from 2 nd column

P.V.P.MOhan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-26 : 02:29:52
isnt this join condition enough?


Col1 + Col2 = Col3



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-26 : 02:30:24
isnt this join condition enough?


Col1 + Col2 = Col3



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

mohan123
Constraint Violating Yak Guru

252 Posts

Posted - 2013-07-26 : 03:23:45
for example :

1st column : 'A1Ctest'
2nd column : 'to test heart disease'
3 col : 'A1Ctest for to test heart disease'

from 3 rd column i need to compare 1 st and 2nd

plz observe 'for' for 1 st column data and 'for' after 2 nd column data

how can i compare ??? in query side



P.V.P.MOhan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-26 : 03:50:02
Change condition to

Col3 LIKE '%' + Col1 + ' %' + Col2 + '%'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-07-28 : 10:34:02
Is "for" always appended after column 1? In that case, you can write

where col3=col1+' for '+col2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -