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

  • SEARCH
  • Home
  • 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 6475939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:45:53+00:00 2026-05-25T06:45:53+00:00

I have very big problem in my SQL query and i don’t know how

  • 0

I have very big problem in my SQL query and i don’t know how to decide it.
So, i have query:

SELECT * FROM table1 WHERE leftBorder <= 10 AND rightBorder >= 100

It’s ok.

Next step.

SELECT * FROM table1 WHERE 
(leftBorder <= 10 AND rightBorder >= 100) OR (leftBorder <= 200 AND rightBorder >= 500)

It’s ok.

But, i’d like to take values of left and right border from query, so:

SELECT * FROM table1 WHERE 
???
(SELECT leftBorder, rightBorder FROM table2 WHERE id in (1,2,3,4,5))

I need to make multi-condition for query in query… Is it possible?
I don’t have procedure, just query.

I try to explain you:

SELECT TOP 1 leftBorder, rightBorder FROM table2 WHERE id in (1,2,3,4,5)

this return me 1 row with leftBorder and rightBorder and i can use it in query like:

SELECT * FROM table1 WHERE 
table1.leftBorder <= table2.leftBorder AND table1.rightBorder >= table2.rightBorder 
(SELECT TOP 1 leftBorder, rightBorder FROM table2 WHERE id in (1,2,3,4,5)) as table2

BUT! It works just when i have 1 row return from query. But what should i do, if i have 10 rows in return and i have to generate query for 10 conditions? Could i do it in query?

  • 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-25T06:45:54+00:00Added an answer on May 25, 2026 at 6:45 am

    You can do this using EXISTS condition :

      SELECT * 
      FROM table1 
      WHERE EXISTS
        (SELECT * 
            FROM table2 
            WHERE table2.leftBorder>=table1.leftBorder 
            and table2.rightBorder<=table1.rightBorder)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very big problem. I am making a CRM (Costumer Relationship Management)
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very big problem and can't seem to find anybody else on
So, this is my problem: I have this very big image, and I want
I have a very big problem solving this issue I have 2 tables first
I have this query in MS SQL which is acting very weird (at least
I have a very big file 4GB and when I try to read it
I have a very big constant array that is initialized at compile time. typedef
I have always been a very big fan of the DHTML calendar http://www.dynarch.com/projects/calendar/ I
I have an element which may contain very big amounts of data, but I

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.