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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:40:22+00:00 2026-05-27T23:40:22+00:00

I have two tables and need to search for all entries that exist in

  • 0

I have two tables and need to search for all entries that exist in one table in another table by idProduct, only if the date (dateStamp) is less than or older than 7 days.

Because the api I’m using is restricted to only processing 3000 results at a time, the application will close and the next time I run the application I only want the idProducts that are say 3000 or greater for that idProduct, this will be run numerous times for the Suppliercode wll most likely already exist in the table.

So I’ve been looking at the not exists and getdate functions in sql but not been able to get the desired results.

SELECT
   *
FROM
   products
WHERE
   (active = - 1)
   AND suppliercode = 'TIT'
   and (NOT EXISTS
     (SELECT
         idProduct
      FROM compare
      WHERE
         (products.idProduct = idProduct)
         OR (compare.dateStamp < DATEADD(DAY,-7,GETDATE()))))

Any pointers would be great, I’ve changed the OR to AND but it doesn’t seem to bring back the correct results.

  • 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-27T23:40:23+00:00Added an answer on May 27, 2026 at 11:40 pm

    I am guessing you want to match the rows in the two tables by idProduct as right now your inner query (NOT EXISTS (SELECT idProduct FROM compare WHERE (products.idProduct = idProduct) OR (compare.dateStamp < DATEADD(DAY,-7,GETDATE())))) looks like it is finding all rows that don’t match. As your subquery finds all rows that match or where the date is older than 7 days and makes sure that they don’t exist.

    Is this what your want?

    SELECT * 
    FROM products as p
    LEFT JOIN compare as c
        ON p.idProduct = c.idProduct
    WHERE p.active = -1 and p.suppliercode = 'TIT' and c.dateStamp < DATEADD(DAY,-7,GETDATE())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I have two tables described below. What I need is a single query that
I have a two tables that are Subject and chapter . I need to
I have two tables. Student and Job. I need to search students who possess
I have two tables, one with all of the postcodes in the UK together
I have two tables, table1 and table2. I need to search occurrence of table1.col1
I have two tables : teachers (teacher_id,teacher_name) courses (teacher_id,course_id) And I need to display
I have two tables with a weak relation. I need get a text value
I have two tables like the ones below. I need to find what exchangeRate
I have two tables: Campaigns, Campaign_statistics. I need to output campaigns list with nested

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.