# Error while using metadata-based filtering

**URL:** https://forum.qiime2.org/t/error-while-using-metadata-based-filtering/3476
**Category:** User Support
**Created:** [March 19, 2018, 2:35pm UTC](https://forum.qiime2.org/t/error-while-using-metadata-based-filtering/3476 "2018-03-19T14:35:42Z")
**Posts on this page:** 1
**Showing post:** 17

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [April 26, 2018, 9:23pm UTC](https://forum.qiime2.org/t/error-while-using-metadata-based-filtering/3476/17 "2018-04-26T21:23:52Z")

</div>

Hey there @MartinLubell!

> [@MartinLubell](#):
>
> Is there an easier way, and I am just missing the boat!?

Hopefully we can help you out!

Hidden away at the end of [this section of the Filtering data tutorial](https://docs.qiime2.org/2018.4/tutorials/filtering/#taxonomy-based-filtering-of-tables-and-sequences) is this little hint:

> If your filtering query is more complex than those supported through `qiime taxa filter-table`, you should use `qiime feature-table filter-features`.

Sounds like you are a perfect candidate for this, since your query is becoming a bit complex now, and `feature-table filter-features` supports [SQL-based queries](https://docs.qiime2.org/2018.4/tutorials/filtering/#metadata-based-filtering), which are super powerful!

So, let's rewrite you command to work with this:

```bash
qiime feature-table filter-features \
  --i-table table.qza \
  --m-metadata-file taxonomy.qza \
  --p-where "Taxon='k __Bacteria' OR Taxon LIKE 'k__ Bacteria; p __Planctomycetes; c__ Planctomycetia; o __Pirellulales; f__ Pirellulaceae%'" \
  --o-filtered-table filtered-table.qza

```

(double-check my spelling in that long taxon string - I am sure I typoed somewhere...)

What this `SQL` clause is saying is: I want all the features that have the exact (`=`) taxon string of `k__Bacteria`. I also want (`OR`), all the features that start with (`LIKE`; `%` at the end of the query string which is a wildcard match) `k__Bacteria; p __Planctomycetes; c__ Planctomycetia; o __Pirellulales; f__ Pirellulaceae`.

Hope that helps! Let us know how it goes! 🦖

---

_[View the full topic](https://forum.qiime2.org/t/error-while-using-metadata-based-filtering/3476)._
