View Single Post
Old 02-09-2003, 04:40 PM   #5 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
Quote:
Originally posted by sde
that query should not be case sensitive .. so if it returns any more than 0 results, .. there is a 'Trevor' or 'trevor' already existing in your system.
ansi sql is not case sensitive*. that is, the operators are not. so:

"select * from users"
is the same as:
"SELECT * From UsErs"

* mysql, as usual, breaks the standard and enforces case sensitivity on object names (ie, tables and columns).

however, data comparisons certainly are case sensitive. if you want to find out if you have any instances of "trevor" in your user db, regardless of case, you will have to do this:

PHP Code:
<?
  $sql 
"select * from users where LOWER(name)='".strtolower($username)."'";
?>
Quote:
PHP Code:
$result=mysql_query("select * from users where username='$username'"); 
the above code is wrong, because if 'TREvor' was already in the database, it would not find it.

of course, you'd not use the sql LOWER() function in high performance situations, since it has to lowercase every username in the database for comparison. but once you've reached that point, i'm sure you'd know better already.
joe_bruin is offline   Reply With Quote