Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
shrike82
Jun 11, 2005

I have a table of book titles of which I only want titles that start with the letters A-K. Also, if the titles start with "A" or "An" or "The", ignore the first word and check on the 2nd word instead.

My first thought was to do a
WHERE Title REGEXP "(A |An |The )?[A-K]"
but it doesn't seem to be greedy so
"An T..." would be accepted. Is there a clean way to do this?

Also, does MySQL support REGEXP groupings? I can't seem to find a way to do so. I want to do a ORDER BY (Title REGEXP blah) where the first word is dropped if it is "A", "An" or "The".

Or is there a cleaner way to do all this in MySQL without touching REGEXPs?

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply