# Case sensitive search?

**URL:** <https://www.ruby-forum.com/t/case-sensitive-search/90484>\
**Category:** Rails\
**Created:** [March 29, 2007, 4:05am UTC](https://www.ruby-forum.com/t/case-sensitive-search/90484 "2007-03-29T04:05:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [March 29, 2007, 4:05am UTC](https://www.ruby-forum.com/t/case-sensitive-search/90484/1 "2007-03-29T04:05:14Z")

</div>

Hello,

I have a login field in the db. when I give find\_by\_login(‘Abc’). And  
there is no login as ‘Abc’ but there is ‘abc’, then it returns that it  
exists. Shouldn’t this be case sensitive by default? If not then how can  
I do a case sensitive search?

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [March 29, 2007, 4:20am UTC](https://www.ruby-forum.com/t/case-sensitive-search/90484/2 "2007-03-29T04:20:05Z")

</div>

Rm Rm wrote:

> Hello,
> 
> I have a login field in the db. when I give find\_by\_login(‘Abc’). And  
> there is no login as ‘Abc’ but there is ‘abc’, then it returns that it  
> exists. Shouldn’t this be case sensitive by default? If not then how can  
> I do a case sensitive search?

That’s a database thing. E.g. for MySQL:

[http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html](http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html)

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [March 29, 2007, 4:40am UTC](https://www.ruby-forum.com/t/case-sensitive-search/90484/3 "2007-03-29T04:40:07Z")

</div>

Rm Rm wrote:

> So, how do I get around it when using mysql & find\_by?

If you want to use find\_by you’ll need to alter your table. Otherwise  
you can write some custom SQL to do the select. Read the page I linked  
to in my previous post.

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [March 29, 2007, 4:25am UTC](https://www.ruby-forum.com/t/case-sensitive-search/90484/4 "2007-03-29T04:25:02Z")

</div>

So, how do I get around it when using mysql & find\_by?

Michael W. wrote:

> Rm Rm wrote:
> 
> > Hello,
> > 
> > I have a login field in the db. when I give find\_by\_login(‘Abc’). And  
> > there is no login as ‘Abc’ but there is ‘abc’, then it returns that it  
> > exists. Shouldn’t this be case sensitive by default? If not then how can  
> > I do a case sensitive search?
> 
> That’s a database thing. E.g. for MySQL:
> 
> [http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html](http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html)
> 
> –  
> Michael W.

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [March 29, 2007, 4:50am UTC](https://www.ruby-forum.com/t/case-sensitive-search/90484/5 "2007-03-29T04:50:48Z")

</div>

Thanks.

Michael W. wrote:

> Rm Rm wrote:
> 
> > So, how do I get around it when using mysql & find\_by?
> 
> If you want to use find\_by you’ll need to alter your table. Otherwise  
> you can write some custom SQL to do the select. Read the page I linked  
> to in my previous post.
> 
> –  
> Michael W.
