It's difficult to follow what you're describing here. Are you saying that depending on which date range is being searched, a different table name and schema should be used? If so, load them all up as separate Class::DBI classes and choose which one to run the search against in your CGI. If this isn't what you meant, maybe you could show us an example of the SQL you would write to do this by hand?