The LIKE keyword and whitespaces.

Discussion in 'Databases' started by mahmood, Dec 14, 2007.

  1. #1
    Am I right that the "LIKE" keyword trims whitespaces from a word for exmaple if I do: "SELECT * FROM myTable WHERE description LIKE '% pet %'" it will be consider the same as "SELECT * FROM myTable WHERE description LIKE '%pet%' "

    If I am right what do I do about it?
     
    mahmood, Dec 14, 2007 IP
  2. MakeADifference

    MakeADifference Peon

    Messages:
    476
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It will not be the same. If you do not need the whitespace, you need to add trim($var) for the string that you want to search on.
    %pet% will return everything that has pet

    % pet % will return every record where there is ' pet ' (with space) is present
     
    MakeADifference, Dec 14, 2007 IP