Jump to content


Photo

need query to retrieve names whose first letter is in a range e.g. A-H


  • Please log in to reply
1 reply to this topic

#1 mgm_03

mgm_03
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts
  • LocationFort Worth, TX

Posted 28 October 2006 - 07:42 PM

I need a query that will retrieve rows based on the first letter of the product name. The user will choose from A-G, H-P, or R-Z (maybe the ranges will be more granular) and I need to return all the products whose name begins with a letter in one of those ranges.

I am guessing that a regex is needed but after that I'm clueless. Any advice is appreciated and if there's an explanation somewhere on the web, pls point me there. I'm not sure what to google for.

**RESOLVED ***

select * from products where name regexp '^[a-g|A-G]'
Guru?...in my dreams!
Sorry Everybody

----------------------

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 October 2006 - 10:42 PM

Actually, you don't need to OR, since matches are generally case-insensitive anyway.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users