Jump to content


This topic is now archived and is closed to further replies.


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

Recommended Posts

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.


select * from products where name regexp '^[a-g|A-G]'

Share this post

Link to post
Share on other sites
Actually, you don't need to OR, since matches are generally case-insensitive anyway.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.