Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi All,

Iam having two tables A and B. Table A having Column Address and table B column Add1.
I have to compare Address and Add1 using like operator

For Example Address having value '404 First avenue' and Add1 having value '404'
I need this row.

SQL
Table A :

   Address          
----------------    
404 First avenue    
404 First avenue    
404 First avenue    

Table B:

Add1
----
second
404
231


My required output is

Address           Add1
------------------------
404 First avenue  404
Posted
Updated 12-Jun-13 21:52pm
v3
Comments
raeeschaudhary 12-Jun-13 6:33am    
LIKE 404%
kirthiga S 12-Jun-13 6:38am    
How to modify this one to get my result..

select * from A join B on a.code=b.code where Address like '%Add1%'

1 solution

Use charindex[^]
e.g.
SQL
select * from A inner join B on a.code=b.code where charindex(B.Add1, A.Address) > 0
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900