-
Notifications
You must be signed in to change notification settings - Fork 664
How to filter an array using an array
agershun edited this page Dec 28, 2014
·
2 revisions
Source: StackOverflow.com
I am trying to look at every value in one array and see if any of them are contained in any of the other array values.
arrOne = ['a', 'b' ,'c' ];
arrTwo = ['option a', 'option c', 'option b', 'option d'];
So I want it to cycle through to see every value in arrTwo that has one of the values from arrOne and remove the ones that don't so I get:
arrFinal = ['option a', 'option c', 'option b'];
var res = alasql('SELECT COLUMN _ FROM ? arrTwo WHERE EXISTS( \
SELECT _ FROM ? arrOne WHERE arrTwo._ LIKE "%"+arrOne._+"%")',
[arrTwo, arrOne]);
Try this example in jsFiddle
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo