Prototype for DB query advanced