Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    32

    Question Unanswered: Case non sensitive select statement

    I am creating a php form that gathers imput for a sql statement where clause. I need it to cope with the user typeing in upper or lower case. So I plan on converting the users entry to lower case and want to write the where clause to also convert the data its comparing to lower case. Does anyone know the best way to do this?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Code:
    WHERE lower(the_column) = lower($input)
    Don't know if the PHP syntax is correct, but that's basically what I'd try.

  3. #3
    Join Date
    Nov 2004
    Posts
    32

    Cool Thank You

    That's excellent thank you! Just for you info the php syntex is = strtolower($input)

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by tmccollum
    That's excellent thank you! Just for you info the php syntex is = strtolower($input)
    Be careful with that. I deliberately wrote it as an SQL function. If you use the PHP function, make sure that special characters (that is non-7bit ASCII) characters are converted the same way by PG and PHP.
    Otherwise you might not get correct results. If you can pass a variable to PG's lower() function, you are on the safe side, because both lower() conversions are identical. As an example: make sure that lower('') is the same as strtolower('') (or whatever special characters you might have)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •