How to search a database of titles with specific contraints