Re: ** Regexp **
== Quote from validus (validus1@gmail.com)'s article
> I'm having trouble trying to figure out some MySQL regexp. Say I'm
> searching for any one of 3 terms.
> I know I can use
> select id,desc from db where desc regexp "red|white|blue";
> This works fine but what if we wanted to be able to match ALL of those
> terms but not in any particular
> order? The 6 potential orders is what is messing me up
> red white blue
> red blue white
> white red blue
> etc.
> I do not want to use a full text search due to using InnoDB tables
> and foreign keys.
> Is there a regexp or am I limited to using multiple like conditions
> which could really be a pain not to mention
> inefficient?
> Cheers,
> validus
i guess one thing you can do is:
select id,desc from db where desc regexp "red|white|blue" or regexp
"red|blue|white" or desc regexp "white|blue|red" (and all the rest of them);
--
POST BY: lark with PHP News Reader
|