Only allow relationship based on "category" checkboxes?

This isn't really a problem with Xataface, but any assistance would be most welcome. I've set up a category checkbox system for one of my tables, almost exactly as described in method 3 here.
Now I want to implement the relationships to that table in a very specific way. I've got two relevant relationship tabs, both of which are many-to-many. I'd like these tabs to only be accessible (and, conversely, the record to only appear on the other end of the relationship) if a specific category is selected in the aforementioned category system (different category for each tab). I just can't figure out the SQL for such a query.
Now I want to implement the relationships to that table in a very specific way. I've got two relevant relationship tabs, both of which are many-to-many. I'd like these tabs to only be accessible (and, conversely, the record to only appear on the other end of the relationship) if a specific category is selected in the aforementioned category system (different category for each tab). I just can't figure out the SQL for such a query.
