Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4619030
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:22:08+00:00 2026-05-22T02:22:08+00:00

I want to make a search using between clause over a string column. Doing

  • 0

I want to make a search using “between” clause over a string column. Doing some test I got this:

Let’s assume that there is a country table with a “name” column of type varchar. If I execute this query:

Select * from country where name between 'a' and 'b'

I got this result:

Argentina
.
.
.
Argelia.

It excludes those countries that starts with B which I found a little bit weird.

Is there a way to do this search in a more accurate way? Any other ideas for make this search?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:22:08+00:00Added an answer on May 22, 2026 at 2:22 am

    The expression

    name between 'A' and 'B'
    

    is equivalent to

    name>='A' and name<='B'
    

    So ‘Argentina’ is >=’A’ and <=’B’ and it satisfies the condition. But ‘Bolivia’ is NOT <=’B’. ‘Bolivia’>’B’. It doesn’t just look at the first letter: it looks at the whole string. Which is surely the way it ought to be: if it didn’t do this, there’d be no way to say that you wanted a range that included ‘Smith’ but not ‘Smithers’.

    To accomplish what you want, you could say:

    substr(name,1,1) between 'A' and 'B'
    

    or:

    name like 'A%' or name like 'B%'
    

    or:

    name>='A' and name<'C'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a dropdown menu like delicious has at this http://delicious.com/search?context=all&p=sql&lc=1 page.
Let's say I want make some of my sources publicly available via my blog
I'm using CakePHP search plugin http://cakedc.com/downloads/view/cakephp_search_plugin and want to make an arg to search
I want to create a stored procedure to do some combined keyword search using
I want to make a program that will search and replace some words occurrence
I have 3 tables, and I want to make a query for a search
I want make datetimepicker in my project. Using jquery how it is possible? I
I am traversing a HTML document using javascript DOM. I want make a list
I can make a search query using these tokens here: http://developers.facebook.com/docs/api#search in the links:
I have to make a string by using the values which the user selects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.