Storing a case insensitive varchar in PostgreSQL
If the tables are not yet populated you may consider simply converting to a standard upper or lower case prior to doing any insertions and making the field a primary key (or just have a unique constraint). If the user want to see his userid in the case he specified this could be another column in the database.
Update:Based on the updated tags I would still suggest the solution I have proposed as being less dependent on a particular DBMS.