views:

80

answers:

3

Hi there,

Is there any way that i can cause mysql to be case sensitive whe searching using where x like '%No.%';

+3  A: 

You could change the column type:

create table my_table (case_sensitive_column VARCHAR(10)) CHARACTER SET latin1 COLLATE latin1_bin;

EDIT Actually, jwsample's answer is better because you don't have to modify the table.

dcp
Unless you always do it, then yours is better ;-)
jwsample
A: 

http://sqlserver2000.databases.aspfaq.com/how-can-i-make-my-sql-queries-case-sensitive.html

http://aspadvice.com/blogs/ssmith/archive/2007/09/30/Case-Sensitive-or-Insensitive-SQL-Query.aspx

griegs
Answering the question is typically better than providing a link that might be dead in 5 years when someone else finds this question.
Jherico
But he's using mysql, not SQL Server.
dcp
@JHerico, if this question is still relevant in 5 years....
griegs
The link could be dead tomorrow.
Hailwood
@griegs, MySQL is already 15 years old. Why wouldn't this question be relevant in 5 years.
Jherico
+4  A: 

Try this:

SELECT * FROM <table> WHERE <column> COLLATE latin1_bin LIKE '%No.%'
jwsample
+1: Beat me, here's a supporting link: http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html Collations with "ci" are case insensitive, while "cs" means case sensitive...
OMG Ponies