Re: MySQL regexp

From: Date: Tue, 25 Jul 2000 12:09:43 +0000
Subject: Re: MySQL regexp
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8013@lists.php.net to get a copy of this message
yeah, but i need to match non-word characters before and after $search, because if i search for "man", i don't want to return results like "hunstman" and "manage", so i need the [[:<:]] and [[:>:]] which means it needs to be regexp so, i'll ask again, how do i specify a case-insensitive pattern match in a mysql_query? chris ----- Original Message ----- From: David Robley <huntsman@www.nisu.flinders.edu.au> To: <chris@nodalplane.freeserve.co.uk> Cc: <php-general@lists.php.net> Sent: Tuesday, July 25, 2000 2:09 AM Subject: Re: [PHP] MySQL regexp > On 25 Jul, Chris Dowell wrote: > > could anyone just point out the extra parameter i need to stick in > > here to make this search case-insensitive, i'm guessing it's going to > > be "i", but where should it go... > > > > $result = mysql_query("select * from atable where acolumn regexp > > '[[:<:]]$search[[:>:]]'"); > > > > thanks > > > > chris > > That's doing it the hard way. In Mysql, LIKE gives a case-insensitive > search, so you could just do > > select * from atable where acolumn LIKE '$search' > > or if you want results that contain $search, wildcards used thus: > > select * from atable where acolumn LIKE '%$search%' > > Cheers > -- > David Robley | WEBMASTER & Mail List Admin > RESEARCH CENTRE FOR INJURY STUDIES | > http://www.nisu.flinders.edu.au/ > AusEinet | > http://auseinet.flinders.edu.au/ > Flinders University, ADELAIDE, SOUTH AUSTRALIA > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#8013) next »