# Query Dataset to check if row contains any from a set of values

For a given keyless dataset, I can query to return the rows whose columns contain a specific value. For example:

ds = Dataset[{{"a", "b"}, {"c", "d"}, {"e", "f"}, {"g", "h"}}]
Query[Select[#[[2]] == "f" &]]@ds


returns the dataset {e,f}.

But, in this simple example, I would like to test:

 Query[#[[2]]=="f"||#[[2]]="g"&]]@ds


How can I perform this operation without writing out every value of interest. For example, I want check if #[[2]] contains any value from the list"check":

check={"f","g"}


ds[GroupBy[#[[2]]&][check] changes the dataset structure. I just want to remove rows from the original dataset.

• You could do Query[Select[MemberQ[check, #[[2]]] &]]@ds, for example. – Leonid Shifrin Jun 18 '15 at 14:04
• Slick--I had been trying MemberQ but not implementing it correctly. Please add as an answer so that I can give credit. – Docuemada Jun 18 '15 at 14:08
• @LeonidShifrin may not see your comment. You can "ping" a user by adding the @ sign before their name, as I did at the beginning of this message. In case he was not interested in converting his comment into an answer, though, I'd urge you to do that yourself (self-answering is encouraged on Stack Exchange) so your question will have a full answer and will be more appealing to future users who encounter similar problems. – MarcoB Jun 19 '15 at 2:57
• Ok, posted an answer as requested. – Leonid Shifrin Jun 19 '15 at 9:33

Query[Select[MemberQ[check, #[[2]]] &]] @ ds