Gossamer Forum
Home : General : Databases and SQL :

SQL Unique User Name Problem

Quote Reply
SQL Unique User Name Problem
I have been trying to find a method of using .asp, access and sql to create a login / register page for my web site. What I need to do is have a unique user name in the user name field. I have created the rest of the registration section apart from this.

In other words I need a way to check that the value of user name I am passing is not equal to any user name in my database.

The best way to go about this I am not sure any advice?
Quote Reply
Re: [david_ste] SQL Unique User Name Problem In reply to
SELECT User_Id FROM User_Table WHERE User_Name = 'the_username'

If User_Id exists then you've got a duplicate.

Last edited by:

Paul: May 14, 2003, 5:40 AM
Quote Reply
Re: [david_ste] SQL Unique User Name Problem In reply to
You should use the UCASE function (for Access) and UPPER (for SQL Server) for the column name and also convert the value being passed into upper case, in order to do a more accurate check.

Since if you use Paul's example without any upper case referencing, duplicates can be entered.

Example:

User A types in 'theMAN'

User B types in 'THEMAN'

Without checking by Upper Case by both the column name and the parameter being passed, then you will get duplicates.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] SQL Unique User Name Problem In reply to
Sorry, you're not correct on that, at least with MySQL, I don't know about access.

Unless the column is binary then the case won't matter and my suggestion will work fine. I just tested to make sure. I entered "paul" into a test table and using:

WHERE User = 'paul'

and...

WHERE User = 'PAUL'

....both worked.
Quote Reply
Re: [Paul] SQL Unique User Name Problem In reply to
Paul,

Yes, I am CORRECT with MS ACcess, you have to use UCASE checking since it uses exact pattern matching...Tongue. And also with SQL Server, you need to use UPPER since again exact pattern matching is used.
========================================
Buh Bye!

Cheers,
Me