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 9145591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:33:09+00:00 2026-06-17T10:33:09+00:00

Below is my database schema. id from to value 1 1 10 5 2

  • 0

Below is my database schema.

id   from  to    value
1    1     10    5
2    11    NULL  10   -- I have stored 'NULL' for any value GREATER THAN 11

Now i have to select value where input like (4) is between from and to.

I know that it can be achieved with this query.

SELECT *
FROM   TABLE
WHERE  4 BETWEEN `from` AND `to`

But how to select value where input is like 15?

SELECT *
FROM   TABLE
WHERE  15 BETWEEN `from` AND `to`

In this case above query will not work because to column has null.

UPDATE

columen to will contain null if it can have any value.

Now If input value is 15, then query should return 2nd row, because 15 is not between 1 and 10 in 1st row and 15 is greater than 11 and to value can be anything greater than 11.

  • 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-06-17T10:33:10+00:00Added an answer on June 17, 2026 at 10:33 am
    SELECT *
    FROM   TABLE
    WHERE  15 BETWEEN coalesce(`from`,15) AND coalesce(`to`,15);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model where I select the proper data from database as below:
I have the below query in a postgresql database SELECT * FROM accounts where
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
When I use below code query database, I cannot get any result, but I
Code below is used to save PostgreSql database backup from browser in Apache Mono
The example below is from a REST database driver on Python 2.7. In the
Consider the below situation I have a database table as below user_id user_rank ------------------
I am working on a site that has a database schema like a tree.
I have a datagrid like below in my WPF application. <Window x:Class=MyApp.TestWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml>
I have my default schema declared in persistence.xml as: <property name=hibernate.default_schema value=MYSCHEMA /> However,

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.