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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:37:06+00:00 2026-06-11T18:37:06+00:00

I have two tables that are connected via a Foreign Key. In table A

  • 0

I have two tables that are connected via a Foreign Key. In table A I’m trying to get all the rows where the data in the time column is greater than or equal to the table B start column and where the data in the time column is less than or equal to the table b end column. I was thinking that an inner join might work for this, however, the results are not what I expected. It is returning some data but they are repeating themselves.

Here is what I have:

SELECT * FROM columnA
INNER JOIN columnB
ON columnA.time >= columnB.start
OR columnA.time <= columnB.stop

Am I looking at this wrong? Is an inner join even the right way of collecting this data?

UPDATE:

Actually tableA’s Foreign Key is connecting to the Primary Key on tableB. Anyways I did this:

SELECT * FROM tableA
INNER JOIN tableB
ON tableA.time >= tableB.start
AND tableA.time <= tableB.stop

The reason I didn’t do what you did for the on is because the data has been in the database for a couple years now and I just recently added the column with the foreign key. So that column doesn’t have any data in it yet. That’s why I’m querying it so I can know which columns to update with the information. It returned the data to me but also returned other data that didn’t meet the requirements.

  • 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-11T18:37:07+00:00Added an answer on June 11, 2026 at 6:37 pm

    I managed to figure out the solution by adding a WHERE to match it the data in the exact row I was looking for. Here is my solution:

    SELECT * FROM tableA
    INNER JOIN tableB
    ON tableA.timetag >= tableB.start
    AND tableA.timetag <= tableB.stop
    WHERE tableB.id = "1"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that are connected via a join table in a many-to-many
I have two tables that should be joined together by a foreign key relationship,
I have two tables that are related via a mapping table: keywords titles I
Suppose I have two tables that are linked (one has a foreign key to
I have two tables (Tasks and Timeentries), which are connected by a foreign key
I have two tables as tblDocument, tblDocVersions connected using primary key docid as follows:
I'm simply trying to get data from two sql server db tables using ado.net
I have two tables that link together through an id one is submit_moderate and
I have two tables that have virtually identical content and very similar structure. They
I have two tables that I want to join together. Table1 Year, ID, Theme,

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.