Skip to content
Advertisement

SQL Join with partial string match

I have a table ‘TableA’ like:

Another table ‘TableB’ like:

I am using INNER JOIN between two tables like:

I want to add another condition for join, which looks for value of ‘Group’ in ‘Subgroup’ and only joins if the ‘Group’ Value matches after ‘XX-‘ and before ‘-XX’.

In other words, join only if Group ‘AB’ shows up at the correct place in Subgroup column.

How can I achieve this? I am using MSSQL

Advertisement

Answer

Try this:

User contributions licensed under: CC BY-SA
11 People found this is helpful
Advertisement