Check to see if there are any matching ids before trying to use in SQL

This fixes a MySQL error
Merge pull request #1 from borkweb/facet-taxonomy-fatal

Check to see if there are any matching ids before trying to use in SQL