Re: MySQL regexp
| From: | David Robley | Date: | Tue, 25 Jul 2000 01:09:10 +0000 |
| Subject: | Re: MySQL regexp | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7977@lists.php.net to get a copy of this message | ||
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