List:General Discussion« Previous MessageNext Message »
From:toxalot Date:August 4 1999 4:48pm
Subject:LIKE operator
View as plain text  
I'm having trouble understanding how LIKE works.

IF I use 
$keyword = 'discover';
SELECT pro_id FROM profiles WHERE profile LIKE "$keyword"

It should match only instances of discover and not discovery, right?

Will it match discover even if the instances of discover has a space on
each side?

The above gives me no results.

Or do I have to use

SELECT pro_id FROM profiles WHERE profile LIKE "%$keyword%"

I've tried a few different scenarios and I can't seem to get consistent
results.

IF I try

$keyword = 'discover';
SELECT pro_id FROM profiles WHERE profile LIKE "%$keyword%"

I get all kinds of matches, but if $keyword = ' discover '; I get 2 matches.

I thought that 

$keyword = ' discover ';
SELECT pro_id FROM profiles WHERE profile LIKE "%$keyword%"

and 

$keyword = 'discover';
SELECT pro_id FROM profiles WHERE profile LIKE "$keyword"

would be the same results.

Thanks for your help

Jennifer
Thread
LIKE operatortoxalot4 Aug
  • Re: LIKE operatorThimble Smith4 Aug
    • Re: LIKE operatortoxalot4 Aug
RE: LIKE operatoradhir4 Aug
  • Re: LIKE operatorThimble Smith4 Aug
RE: LIKE operatoradhir4 Aug
  • RE: LIKE operatortoxalot5 Aug
    • Re: LIKE operatorThimble Smith5 Aug
Re: LIKE operatorChristian Mack5 Aug
RE: LIKE operatoradhir5 Aug