List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:January 29 2002 8:27pm
Subject:Re: Please Help with Pattern Matching
View as plain text  
In the last episode (Jan 29), Douglas Brantz said:
> I have a big problem with pattern matching;
> Why does the first example work like this I need to find everything with
> MWF in it and I only get the 1 entry?  Is there a way I can make this
> work.
> 
> mysql> select schdays from courses where schdays LIKE "%MWF%";
> | MWF     |
> 
> mysql> select schdays from courses where schdays LIKE "%M%";
> | MWF     |
> | MW      |
> | MW      |
> | M       |
> | M       |

I see nothing wrong here.  Your first statement says "give me all rows
with the string MWF in schdays".  Your second statement says "give me
all rows with the string M in schdays".

If you want all rows with M, W, or F in schdays, you'll want something
like WHERE schdays LIKE "%M%" OR schdays LIKE "%W%" OR schdays LIKE
"%F%".

-- 
	Dan Nelson
	dnelson@stripped
Thread
Please Help with Pattern MatchingDouglas Brantz29 Jan
  • Re: Please Help with Pattern MatchingPaul DuBois29 Jan
  • RE: Please Help with Pattern MatchingGurhan Ozen29 Jan
    • Pattern Matching SolvedDouglas Brantz29 Jan
  • Re: Please Help with Pattern MatchingDan Nelson29 Jan
RE: Please Help with Pattern MatchingRoger Karnouk29 Jan