Krishn
Krishn

Reputation: 873

Fuzzy (Like) Join not working

I have the below code to match on similar characters where possible and it only brings through results from subquery A. Please can someone assist? Thanks

    select 
        * 
    from 
        (
            Select 'Test' T
        )a
        left join
        (
            Select 'Test1' T
        )b
    on
        '%' + a.t + '%' 
    like 
        '%' + b.t  + '%'

Upvotes: 0

Views: 48

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270583

The like pattern only goes on the right side of the operator. I think you intend:

on (a.t like '%' + b.t + '%') or
   (b.t like '%' + a.t + '%')

Upvotes: 3

Related Questions