How do I select rows containing part of the values from another list of strings?
In firebird + C # app. I have a table like:
TableA:
30RTabc1 someothervalue1 someothervalue2
30RTabc2 someothervalue3 someothervalue4
30RTabc1 someothervalue5 someothervalue6
30RTabc4 someothervalue7 someothervalue8
30RTabc1 someothervalue9 someothervalue10
TableB:
abc1 someothervalue1 someothervalue2
abc2 someothervalue3 someothervalue4
abc3 someothervalue5 someothervalue6
So, as a result, I will have a merged TableC that will have values from TableA where the first column contains values from the first column of TableB, so it will look like this:
The result of joining TableA + TableB, where row column1 of table A contains the row from column TableB:
TableC:
30RTabc1 someothervalue1 someothervalue2
30RTabc2 someothervalue3 someothervalue4
30RTabc1 someothervalue5 someothervalue6
30RTabc1 someothervalue9 someothervalue10
What's the best way to do this, in firebird some sql query or in an app, C # -loop? (The key is column1, other values can be completely different, someothervalue is just an example, everything can be random)
source to share
If it is easy to do it in SQL, I see no reason to do it in C #, you will need to extract a lot of data and then abandon it.
As far as how to do it in SQL, it depends on the "30RT" part that can be changed or not:
If not:
SELECT t1.*
FROM TableA t1
INNER JOIN TableB t2
ON t1.Key = '30RT'+t2.Key
If it could be anything:
SELECT t1.*
FROM TableA t1
INNER JOIN TableB t2
ON t1.Key like '%'+t2.Key
source to share