For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > August 2006 > Distinct Partial Matches: RegExp









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Distinct Partial Matches: RegExp
Kevin Murphy

2006-08-30, 6:57 pm

This might be really easy, but I'm just not sure how to write this
query and my searching on google isn't finding me things, probably
because I am searching for the wrong terms.

I have a bunch of records where the "area" column is like:

animal-dog-5
animal-dog-3
animal-cat-1
animal-cat-22
animal-bird-5

What I want to do is run a distinct query on just the part previous
to the number.

animal-dog
animal-cat
animal-bird

So in other words, something like this, but I am not sure if this is
the right way to go:

$query = "SELECT DISTINCT area FROM table WHERE REGEXP
'anynumberofletters dash anynumberofletters dash '"


Of course, I could be barking up the wrong tree with the REGEXP
thing. Anyone care to point me in the right direction?


--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com