Given a one-dimensional array named A of length X, and a two-dimensional array named B with x one-dimensional arrays inside of different lengths, I want to find out using SQL if all elements of A can be found in B, such that each sub-array in B contains 1 element from A, and all elements of A are divided evenly throughout B. It's not about putting elements into B but checking if the elements of A can already be found in B using these rules.
This sounds and is a bit complicated to explain, so I'll give some examples.
In this case the SQL code would return TRUE, because 2 can be found in B, 3 in B and 1 in B. 3 can also be found in B, 2 in B and again 1 in B, but it just matters that there is at least one way to do this, not which way it is.
In this case the code would return FALSE; because 5 can not be found in any of the B sub-arrays.
In this case the code would return FALSE, because both 1 and 4 are only in B, so whichever one is chosen for that sub-array, the other one can't be found anywhere else.
I hope these examples show what I want to achieve. It seems like it SHOULD be possible to do with a SELECT statement, but I am rather at a loss at how to achieve it. I also have a feeling that this should be a well-known programming problem, such that it has a name (like Knapsack, TSP and such), but I've not been able to find anything about it, and I am not sure what it would be called.
So can I get a nudge or some info on how this should or could be done?