How to create and edit Advanced Queries for custom tables