I have a table like this

```
Rules (RuleValue varchar (50))

```

It has values like

```
A1B1C1
A1B1C0
A1B0C0

```

There is another table

```
Input (RulePart varchar (2))

```

It can have values like:

```
A1
B1
C1

```

I want to get all RuleValues where all the RulePart matches anywhere in the RuleValue
Following is an example with hardcoded RuleParts:

```
Select RuleValue from Rules where Rules.RuleValue like '%A1%' and Rules.RuleValue like '%B1%' and Rules.RuleValue like '%C1%'

```

With the above examples my expected result is A1B1C1 or B1A1C1 or C1A1B1 etc.

I tried to use inner join, but it does not match all the Rule Parts in every row.

I can achieve this using creating query dynamically but don't want to go for that unless it affects query performance.