I have to implement a where clause which should give me the matching substring.

Eg: I have a column destination email in a table called Email. I will send an email to one of the "destination email" plus other id ([email protected]). I am storing all the email addresses added to the "TO Section" of an email (varTo")

Right now, I am using the below query:

    select * from table where destinationEmail= CHARINDEX(DestinationEmail, varTo)>0.

Currently, I am facing an issue with 2 email addresses ([email protected] and [email protected]) which is returning 2 rows. For other emails, this condition returns the correct values without any issues

The exact result what I want is the system should pick the email which exist in the "destinationEmail" and should ignore other emails stored in the varTo section.

Eg: I am sending an email to [email protected]; [email protected]; [email protected] Here, it should return only "[email protected]"

Is it possible to achieve this using a simple where condition?

Many thanks, Manoj

0 Answers