You might just want to use an RDBMS like MySQL instead of rolling your own via some wacky hash. At least, this is what comes to mind first. What you're talking about here is rather murky.
Once in a database like that, you can perform all kinds of queries on your data.