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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to compare 3 columns from 2 tables
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mohan123
Constraint Violating Yak Guru

India
252 Posts

Posted - 07/26/2013 :  02:25:53  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 07/26/2013 :  02:29:52  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 07/26/2013 :  02:30:24  Show Profile  Reply with Quote
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

India
252 Posts

Posted - 07/26/2013 :  03:23:45  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 07/26/2013 :  03:50:02  Show Profile  Reply with Quote
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

India
22864 Posts

Posted - 07/28/2013 :  10:34:02  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000