Sat, 29 Jan 2011

Multiple Crimes

mysql> select "a" = "A";
+-----------+
| "a" = "A" |
+-----------+
|         1 |
+-----------+
1 row in set (0.00 sec)

WTF? (via Nuxeo)

[] | # Read Comments (5) |

Comments

You are using a case-insensitive collation?

mysql> SHOW VARIABLES LIKE 'collation%';
Posted by me at Sat Jan 29 18:27:49 2011
This is true in almost all of the SQL databases that I know, and I would actually have it no other way for the default.  Most of the time, you don't care about case sensitivity.  All the other times, you can use binary, or change the collation of the table to turn off the insensitiveness.
Posted by Michael Janssen at Sat Jan 29 23:42:42 2011
Huch almost all databases?

postgres=> select 'a' = 'A';
?column?
----------
f
(1 row)

sqlite> select 'a' = 'A';
0

That's after fixing the double-quotes that are not allowed by standard SQL
Posted by siccegge at Sun Jan 30 10:39:33 2011
also oracle:

SQL> select case when ('a'='A')  then 1 else 0 end from dual ;

CASEWHEN('A'='A')THEN1ELSE0END
------------------------------
  0

SQL> select case when ('a'='a')  then 1 else 0 end from dual ;

CASEWHEN('A'='A')THEN1ELSE0END
------------------------------
  1
Posted by djadala at Sun Jan 30 12:06:27 2011
> This is true in almost all of the SQL databases that I know, and I would actually have it no other way for the default.


ha

psql=> select 'a' = 'A';
?column?
----------
f
(1 row)
Posted by Mike at Mon Feb 14 16:34:01 2011

Name:


E-mail:


URL:


Comment:


Please enter "fudge" to prove you are a human