Generate where clauses and other filters for SQL queries