Alright so I have two tables. Table1 has an reference number column (A), and a second column that has a string of randomness (B). Table2 has only one column with a list of values that may or may not be in the string on Table1.
dbo.Tbl_1
+--+---------------------------------------+
|A |B |
+--+---------------------------------------+
|24|BLUE; KITTEN; WHITE; PINK; SLOPE; GREEN|
+--+---------------------------------------+
|51|GREEN; CLOUDY; WHITE; CHIPS |
+--+---------------------------------------+
|78|PATRIOTS; PINK; PINK; WHITE |
+--+---------------------------------------+
|22|WHITE; RED; TREES; AMY; GREEN |
+--+---------------------------------------+
dbo.Tbl_2
+-----+
|C |
+-----+
|BLUE |
+-----+
|WHITE|
+-----+
|PINK |
+-----+
|BROWN|
+-----+
What sql query would determine how many times a value from Table2 is found in the string on Table1? Basically I want to return the below result set:
+-----+----+
|BLUE |1 |
+-----+----+
|WHITE|4 |
+-----+----+
|PINK |3 |
+-----+----+
|BROWN|NULL|
+-----+----+
FYI: In reality, Table2 has about 200 unique records. Table1 has about 1.6M records with unique reference numbers. Neither tables are static.