List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:November 4 2009 7:46pm
Subject:Re: Alphabetical search to and from
View as plain text  
At 11:52 PM +0900 11/4/09, Dave M G wrote:
>MySQL,
>
>This should be a fairly simple question.
>
>I have a table with a bunch of people's names. I want to find people
>who's name begins within a certain range of characters.
>
>All names between F and P, for example.
>
>What SELECT statement would I use to do that?
>
>Thank you for any advice.
>
>--
>Dave M G


And to add a few more possibilities:

	select * from your_table where name >= 'F' and name < 'Q'

	select * from your_table where left(name, 1) in 
('f','g','h','i','j','k','l','m','n','o','p')

I wouldn't recommend the latter, but might be handy if you were 
dealing with something more complex than a simple range.

	- steve

-- 
+------------------------------------------------------------------------+
| Steve Edberg                                  edberg@stripped |
| Programming/Database/SysAdmin            http://www.edberg-online.com/ |
+------------------------------------------------------------------------+
Thread
Alphabetical search to and fromDave M G4 Nov
  • Re: Alphabetical search to and fromJay Ess4 Nov
  • RE: Alphabetical search to and frommisiaQ4 Nov
    • Re: Alphabetical search to and fromMichael Dykman4 Nov
      • RE: Alphabetical search to and frommisiaQ4 Nov
        • Re: Alphabetical search to and fromMichael Dykman4 Nov
          • Re: Alphabetical search to and fromJay Ess4 Nov
            • RE: Alphabetical search to and frommisiaQ4 Nov
              • Re: Alphabetical search to and from [SOLVED]Dave M G5 Nov
  • Re: Alphabetical search to and fromSteve Edberg4 Nov