Results 1 to 2 of 2

Thread: frustrated with lcase

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default frustrated with lcase

    Hi, I am using mysql 5.0.67 and am using the following to find the made up term terewS

    Code:
    SELECT ID, summary, category FROM news WHERE (lcase(concat(ID, summary, category)) LIKE '%terews%')
    the above code does not work, but the following does:
    Code:
    SELECT ID, summary, category FROM news WHERE (lcase(concat(ID, summary, category)) LIKE '%terewS%')
    Anyone know what I am doing wrong? I recently ported all of my data over from my MySQL database 4.0 to 5.0.

    The code does work with the 4.0 database. I am looking into it. If I figure out the answer before anyone else does I will post a reply with the solution.
    Last edited by james438; 11-04-2009 at 06:17 PM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    got it. The problem was with concat, not lcase.

    CONCAT(str1,str2,...)

    Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:
    SELECT CONCAT(CAST(int_col AS CHAR), char_col);
    ref

    In other words to fix this I would need to convert my argument to
    Code:
    SELECT ID, summary, category FROM news WHERE lcase(concat(cast(ID as char),summary,category)) LIKE '%terews%'
    The original argument I was using should not have been working, but possibly that was by design prior to MySQL 5.0 series.
    Last edited by james438; 11-04-2009 at 08:51 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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