Match the String in a join

  • i have Two tables T1 , T2

    Create table T1( Activity varchar (100))

    Create Table T2 ( Activity varchar (100))

    T1 table has data as below

    Activity (field)

    SendToUser% (data)

    T2 table data

    Activity (field)

    SendToUser-U12345

    So , both tables should match ...because the string SendToUser% means  "SendToUser"+"....."

    How can i use it in join?

    Select * from T1 Join T2 on left(T1.activity, len(T1.activity)-1)  like Concat('%',T2.activity,'%')

    The above query is not working 🙁

     

     

     

     

  • You have that many points and you can't be bothered to post some consumable data?

    You could join on

    LEFT(TableA[column],8) = LEFT(TableB[column],8)

    • This reply was modified 7 months, 2 weeks ago by  pietlinden.
  • Try this

    Select * from T1 
    Join T2 on T2.activity LIKE CONCAT('%',left(T1.activity, len(T1.activity)-1),'%')

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply