whereNotIn
The whereNotIn
method returns a new table containing rows from the source table, where the rows do not match values in the filter table. The filter is updated whenever either table changes.
whereNotIn
is not appropriate for all situations. Its purpose is to enable more efficient filtering for an infrequently changing filter table.
Syntax
table.whereNotIn(rightTable, columnsToMatch...)
Parameters
Parameter | Type | Description |
---|---|---|
rightTable | Table | The table containing the set of values to filter on. |
columnsToMatch | String... | The columns to match between the two tables.
|
columnsToMatch | Collection | The columns to match between the two tables. |
Returns
A new table containing rows from the source table, where the rows do not match values in the filter table.
Examples
The following example creates a table containing only the colors not present in the filter
table.
source = newTable(
stringCol("Letter", "A", "C", "F", "B", "E", "D", "A"),
intCol("Number", NULL_INT, 2, 1, NULL_INT, 4, 5, 3),
stringCol("Color", "red", "blue", "orange", "purple", "yellow", "pink", "blue"),
intCol("Code", 12, 13, 11, NULL_INT, 16, 14, NULL_INT),
)
filter = newTable(
stringCol("Colors", "blue", "red", "purple", "white")
)
result = source.whereNotIn(filter, "Color = Colors")
- source
- filter
- result
The following example creates a table containing only the colors and codes not present in the filter
table. When using multiple matches, the resulting table will exclude only values that are not in both matches. In this example, only one row matches both color AND codes. This results in a new table that has all but one matching value.
source = newTable(
stringCol("Letter", "A", "C", "F", "B", "E", "D", "A"),
intCol("Number", NULL_INT, 2, 1, NULL_INT, 4, 5, 3),
stringCol("Color", "red", "blue", "orange", "purple", "yellow", "pink", "blue"),
intCol("Code", 12, 13, 11, 10, 16, 14, NULL_INT),
)
filter = newTable(
stringCol("Colors", "blue", "red", "purple", "white"),
intCol("Codes", 10, 12, 14, 16)
)
result = source.whereNotIn(filter, "Color = Colors", "Code = Codes")
- source
- filter
- result