Development MySQL multiple LIKE search not returning expected

Discussion in 'Software' started by Draxin, 24 Sep 2008.

  1. Draxin

    Draxin Seeker of Photons

    Joined:
    29 Nov 2001
    Posts:
    965
    Likes Received:
    5
    running a LIKE query has been easy enough.
    now i need to expand it to allow for more then one search term

    I have the following

    PHP:
    SELECT *
    FROM `table`
    WHERE `fieldLIKE '%TERM1%'
    OR `fieldLIKE '%TERM2%'
    I would have expected it to return anything it found to contain EITHER of those search terms.
    however it only seems to be returning results for TERM2.

    I have data in the fields that match both TERM1 and TERM2

    I have obviously over looked something, googling has had me chasing my tail and the documentation is making my eyes bleed.

    and im running MySQL Server version: 4.1.22-standard so i cant use the newer better features of 5

    any ideas?
     
    Last edited: 24 Sep 2008
  2. theevilelephant

    theevilelephant Minimodder

    Joined:
    5 Jan 2006
    Posts:
    1,334
    Likes Received:
    36
  3. Draxin

    Draxin Seeker of Photons

    Joined:
    29 Nov 2001
    Posts:
    965
    Likes Received:
    5
    Brilliant thank you
     
  4. RTT

    RTT #parp

    Joined:
    12 Mar 2001
    Posts:
    14,120
    Likes Received:
    74
    Your assumption is correct, it should (and does) return for either or bot) term1 or term2.
    RLIKE is a regex version of LIKE and performs no differently to LIKE at all.

    There's absolutely no reason why your original query would not work (there must be some problem with the data in your table) :)
     
  5. Draxin

    Draxin Seeker of Photons

    Joined:
    29 Nov 2001
    Posts:
    965
    Likes Received:
    5
    im starting to think there is something fundamentaly wrong with our MySQL server. because the first query returns a completly different set of results then using the RLIKE query suggested.

    both with the same 2 search terms
     

Share This Page