In sql server, how do I query whether the field in Table An is included in a field in Table B?

has the following two tables:

Table a field:

id,tag

Table b field:

id,title

< H2 > query purpose: < / H2 >

when the tag of table an is contained in the title of table b, it is queried

< H2 > the current code looks something like this: < / H2 >

select a.tag from a with (nolock)
left outer join b with (nolock)
on charindex (a.tagg, b.title) > 0

< H2 > question: < / H2 >

according to my code, it takes a long time to execute. Is there a better way to write it? Thank you!

Jul.22,2021
Menu