List:General Discussion« Previous MessageNext Message »
From:Octavian Rasnita Date:September 11 2005 2:40pm
Subject:Re: Behaviour of like expression
View as plain text  
Yes, in perl is OK, but in MySQL it is not really ok.

Perl regular expressions use ^ and $ for specifying the start and end of the
string while MySQL like operator doesn't

For example, if $string = 'a', // with match in perl, but /^$/ won't match.

MySQL like operator could use '%' for matching everything but it don't have
any way to match only the empty string, because it doesn't have a way of
specifying the start and end of the string.

Teddy


----- Original Message ----- 
From: "Josh Chamas" <josh@stripped>
To: <CGondelach@stripped>
Cc: <mysql@stripped>
Sent: Sunday, September 11, 2005 16:18 PM
Subject: Re: Behaviour of like expression


> CGondelach@stripped wrote:
> > Hi all,
> >
> > I've got a question. We were testing something on our mysql server (
> > 4.0.21) with MyISAM tables.
> >
> > When we executed the query "select * from people where name like '';" we
> > expected the same results as "select * from people where name='';" but
it
> > didn't.
> >
> > The like function returned everything instead of only the people without
a
> > name. Is this known (and correct) behaviour? It does not sound logical
to
> > me. I couldn't find anything about it on the mysql website.
> >
>
> Usually, pattern matching done where a pattern is nothing matches
everything.
>
> Use LIKE for pattern matching, and = for equivalency.
>
> I don't know what the ANSI SQL spec says here, and whether our behavior
> is correct there, but this behavior makes sense to me at least.  I would
> expect similar behavior from perl, for example:
>
> $ perl -e 'my $a = qw(a); print $a =~ //;'
> 1
>
> Regards,
>
> Josh
> -- 
> Josh Chamas
> Director, Professional Services
> MySQL Inc., www.mysql.com
> Get More with MySQL!  www.mysql.com/consulting
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>

Thread
Behaviour of like expressionCGondelach11 Sep
  • Re: Behaviour of like expressionJosh Chamas11 Sep
  • Re: Behaviour of like expressionOctavian Rasnita11 Sep
  • Re: Behaviour of like expressionGleb Paharenko12 Sep
    • Re: Behaviour of like expressionMichael Stassen12 Sep
      • Re: Behaviour of like expressionGleb Paharenko13 Sep