Using a Wildcard as a condition

Hello.

I am trying to use a wildcard in a case statement, but, can't seem to get my head around it.

Select
cct.FinancialAccountNumber,
cct.Amount,
cct.PostedDate,
Match = Case When cct.SystemSequencxeNumber Like (Select ah.TokenString From AccountHistory ah Where cct.MemberNumber = ah.MemberNumber and cct.LoanNumber = ah.AccountNumber) Then 'X' Else '' End

From
CreditCardTransaction cct

Where
cct.PostedDate Between '04/01/2022' AND '04/30/2022'

Basically I'm trying match if anything in ah.TokenString = cct.SystemSequenceNumber

Is that possible? Thanks.


Select
cct.FinancialAccountNumber,
cct.Amount,
cct.PostedDate,
Match = Case When Exists(Select 1 From AccountHistory ah 
    Where cct.MemberNumber = ah.MemberNumber and cct.LoanNumber = ah.AccountNumber and
        cct.SystemSequencxeNumber Like ah.TokenString)
    Then 'X' Else '' End
From
CreditCardTransaction cct

Where
cct.PostedDate Between '04/01/2022' AND '04/30/2022'

Thank you for the response. Unfortunately it didn't return the desired result.

Here is an example of the two fields that I am trying to match

image

image

The TokenString is varchar ... not sure if that makes a difference

If you want to do that, then you condition needs to be:

ah.TokenString LIKE '%' + cct.SystemSequencxeNumber + '%'

Thanks again .... I am getting ...

Conversion failed when converting the varchar value '%' to data type int

ah.TokenString LIKE '%' + CAST(cct.SystemSequencxeNumber AS varchar(10)) + '%'

Boom! Thank you Scott. Appreciate you working through that with me!

You're welcome. Glad it worked out!