Capitalization in PHP

Capitalization in PHP

am 16.04.2008 02:34:22 von Matt White

Hello all,

I'm trying to build a site that searches through a MySQL database of songs.
I need to be able to take user input, and narrow the song list down.
However, if a user types in "C", but the song starts with "c", they will not
the song. Is there anyway to make MySQL ignore capitalization in a request?
I would like to find a way around having to de-capitalize all the songs in
the database, which is my only option right now. Any help would be
appreciated.

Matt White

Re: Capitalization in PHP

am 16.04.2008 04:31:31 von Preventer of Work

Matthew White wrote:
> Hello all,
>
> I'm trying to build a site that searches through a MySQL database of
> songs. I need to be able to take user input, and narrow the song list
> down. However, if a user types in "C", but the song starts with "c",
> they will not the song. Is there anyway to make MySQL ignore
> capitalization in a request? I would like to find a way around having to
> de-capitalize all the songs in the database, which is my only option
> right now. Any help would be appreciated.
>
> Matt White

Mysql searches are no case sensitive. Looking for joE find Joe, joe and JOE.

See the old docs at
http://dev.mysql.com/doc/refman/4.1/en/case-sensitivity.html
or 5.1 docs:
http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html

Re: Capitalization in PHP

am 16.04.2008 21:10:22 von Matt White

I am using a binary coalition that means that my queries are case sensitive.
Any way of getting around that?


"Preventer of Work" wrote in message
news:7ydNj.54107$Cj7.22755@pd7urf2no...
> Matthew White wrote:
>> Hello all,
>>
>> I'm trying to build a site that searches through a MySQL database of
>> songs. I need to be able to take user input, and narrow the song list
>> down. However, if a user types in "C", but the song starts with "c", they
>> will not the song. Is there anyway to make MySQL ignore capitalization
>> in a request? I would like to find a way around having to de-capitalize
>> all the songs in the database, which is my only option right now. Any
>> help would be appreciated.
>>
>> Matt White
>
> Mysql searches are no case sensitive. Looking for joE find Joe, joe and
> JOE.
>
> See the old docs at
> http://dev.mysql.com/doc/refman/4.1/en/case-sensitivity.html
> or 5.1 docs:
> http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html
>

Re: Capitalization in PHP

am 17.04.2008 02:01:06 von Preventer of Work

Matthew White wrote:
> I am using a binary coalition that means that my queries are case
> sensitive. Any way of getting around that?
>
>
> "Preventer of Work" wrote in message
> news:7ydNj.54107$Cj7.22755@pd7urf2no...
>> Matthew White wrote:
>>> Hello all,
>>>
>>> I'm trying to build a site that searches through a MySQL database of
>>> songs. I need to be able to take user input, and narrow the song list
>>> down. However, if a user types in "C", but the song starts with "c",
>>> they will not the song. Is there anyway to make MySQL ignore
>>> capitalization in a request? I would like to find a way around having
>>> to de-capitalize all the songs in the database, which is my only
>>> option right now. Any help would be appreciated.
>>>
>>> Matt White
>>
>> Mysql searches are no case sensitive. Looking for joE find Joe, joe
>> and JOE.
>>
>> See the old docs at
>> http://dev.mysql.com/doc/refman/4.1/en/case-sensitivity.html
>> or 5.1 docs:
>> http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html
>>

You can generate a string to drive a regular expression. It's a bit of
work, but not too much. Here's the idea:

mysql> select * from incase where name = 'joe';
+----+------+
| id | name |
+----+------+
| 1 | joe |
+----+------+


mysql> select * from incase where name REGEXP '[Jj]oe';
+----+------+
| id | name |
+----+------+
| 1 | joe |
| 2 | Joe |
+----+------+

You would take the search string and just generate char pairs in
brackets, so

'Joe' becomes '[Jj][Oo][Ee]'

However, this is easier:

mysql> select * from incase where LOWER(name) = 'joe';
+----+------+
| id | name |
+----+------+
| 1 | joe |
| 2 | Joe |
+----+------+

Re: Capitalization in PHP

am 17.04.2008 02:02:03 von Preventer of Work

Preventer of Work wrote:
> Matthew White wrote:
>> I am using a binary coalition that means that my queries are case
>> sensitive. Any way of getting around that?
>>
>>
>> "Preventer of Work" wrote in message
>> news:7ydNj.54107$Cj7.22755@pd7urf2no...
>>> Matthew White wrote:
>>>> Hello all,
>>>>
>>>> I'm trying to build a site that searches through a MySQL database of
>>>> songs. I need to be able to take user input, and narrow the song
>>>> list down. However, if a user types in "C", but the song starts with
>>>> "c", they will not the song. Is there anyway to make MySQL ignore
>>>> capitalization in a request? I would like to find a way around
>>>> having to de-capitalize all the songs in the database, which is my
>>>> only option right now. Any help would be appreciated.
>>>>
>>>> Matt White
>>>
>>> Mysql searches are no case sensitive. Looking for joE find Joe, joe
>>> and JOE.
>>>
>>> See the old docs at
>>> http://dev.mysql.com/doc/refman/4.1/en/case-sensitivity.html
>>> or 5.1 docs:
>>> http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html
>>>
>
> You can generate a string to drive a regular expression. It's a bit of
> work, but not too much. Here's the idea:
>
> mysql> select * from incase where name = 'joe';
> +----+------+
> | id | name |
> +----+------+
> | 1 | joe |
> +----+------+
>
>
> mysql> select * from incase where name REGEXP '[Jj]oe';
> +----+------+
> | id | name |
> +----+------+
> | 1 | joe |
> | 2 | Joe |
> +----+------+
>
> You would take the search string and just generate char pairs in
> brackets, so
>
> 'Joe' becomes '[Jj][Oo][Ee]'
>
> However, this is easier:
>
> mysql> select * from incase where LOWER(name) = 'joe';
> +----+------+
> | id | name |
> +----+------+
> | 1 | joe |
> | 2 | Joe |
> +----+------+
>
>
Ooops, LOWER() both arguments

Re: Capitalization in PHP

am 19.04.2008 02:07:24 von Matt White

OK, that works. Thanks for the help!

"Preventer of Work" wrote in message
news:%rwNj.194759$pM4.105280@pd7urf1no...
> Preventer of Work wrote:
>> Matthew White wrote:
>>> I am using a binary coalition that means that my queries are case
>>> sensitive. Any way of getting around that?
>>>
>>>
>>> "Preventer of Work" wrote in message
>>> news:7ydNj.54107$Cj7.22755@pd7urf2no...
>>>> Matthew White wrote:
>>>>> Hello all,
>>>>>
>>>>> I'm trying to build a site that searches through a MySQL database of
>>>>> songs. I need to be able to take user input, and narrow the song list
>>>>> down. However, if a user types in "C", but the song starts with "c",
>>>>> they will not the song. Is there anyway to make MySQL ignore
>>>>> capitalization in a request? I would like to find a way around having
>>>>> to de-capitalize all the songs in the database, which is my only
>>>>> option right now. Any help would be appreciated.
>>>>>
>>>>> Matt White
>>>>
>>>> Mysql searches are no case sensitive. Looking for joE find Joe, joe and
>>>> JOE.
>>>>
>>>> See the old docs at
>>>> http://dev.mysql.com/doc/refman/4.1/en/case-sensitivity.html
>>>> or 5.1 docs:
>>>> http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html
>>>>
>>
>> You can generate a string to drive a regular expression. It's a bit of
>> work, but not too much. Here's the idea:
>>
>> mysql> select * from incase where name = 'joe';
>> +----+------+
>> | id | name |
>> +----+------+
>> | 1 | joe |
>> +----+------+
>>
>>
>> mysql> select * from incase where name REGEXP '[Jj]oe';
>> +----+------+
>> | id | name |
>> +----+------+
>> | 1 | joe |
>> | 2 | Joe |
>> +----+------+
>>
>> You would take the search string and just generate char pairs in
>> brackets, so
>>
>> 'Joe' becomes '[Jj][Oo][Ee]'
>>
>> However, this is easier:
>>
>> mysql> select * from incase where LOWER(name) = 'joe';
>> +----+------+
>> | id | name |
>> +----+------+
>> | 1 | joe |
>> | 2 | Joe |
>> +----+------+
>>
>>
> Ooops, LOWER() both arguments

Re: Capitalization in PHP

am 21.04.2008 19:58:30 von unknown

Post removed (X-No-Archive: yes)