Announcement

Collapse
No announcement yet.

How do I get around case sensitivity?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I get around case sensitivity?

    I've created a search feature for my site I'm building, but when I enter a name to get information on a certain game, it doesn't find it unless it is case sensitive

  • #2
    SELECT * FROM table_name WHERE LOWER(field_name)=LOWER('Your String')

    mySQL Docs:
    6.3.2 String Functions

    Comment


    • #3
      Max:

      varchar and text fields are already case insensitive in MySQL, I don't believe that will make a difference.

      Steviepowers:

      You did not specify what kind of code you are using or if you even use a MySQL database, but because you talk of a case sensitivity problem I would assume you are not using MySQL, because most fields in MySQL are case insensitive anyway.

      If you are doing a comparison in PHP, you can use the strtolower() function during the comparison:

      PHP Code:
      if( strtolower($search) == strtolower($game) )
      {
           
      // code here

      Comment


      • #4
        Jeff,

        form my experience these are different.

        scoutt
        Scoutt

        if I was to save that in a text field they would be different. not sure about varchar, but text is case sensitive.

        Comment


        • #5
          Neither varchar nor text fields have been case sensitive any time I've used MySQL and I have done quite a few projects. So I don't know, maybe there is some option I don't know of.

          Comment


          • #6
            Case sensitive or not, that query will work.

            I don't remember ever needing to use it though. So I'm thinking that mySQL is case-insensitive...

            Anywhoo, use whatever works and don't rock the boat.

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            X