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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:26:26+00:00 2026-05-18T04:26:26+00:00

My database consists of 2 tables. Im using MySQL. Table 1 cars = id(int,PRIMARYKEY),

  • 0

My database consists of 2 tables. Im using MySQL.

Table 1

cars = id(int,PRIMARYKEY), reg(int), type(int)

Table 2

jobs = ref(int,PRIMARYKEY), id (int), date(date)

I need a SELECT statement which would get me all the cars which have not had a job in the past 3 weeks.

(i.e: If a car has not had a job in the past 3 weeks, then that car(id) would be returned.)

I know there would be several ways to do this however I am not up to speed in sql yet :<

  • 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-18T04:26:27+00:00Added an answer on May 18, 2026 at 4:26 am

    This is a good use case for NOT EXISTS:

    select c.id,c.reg,c.type
    from cars c
    where not exists 
    (
      select NULL
      from jobs j
      where j.id = c.id
      and j.date >= CURRENT_DATE - INTERVAL 3 WEEK
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple MySQL 5 database that consists of id - Int -
I am returning a result set from a mySQL database into a table using
I'm using Linq2Sql with pipes/filters. My database consists of Accounts and Transactions tables where
I have a MS access database. In that, one table consists of questions and
I am using XDocument to keep a sort of database. This database consists of
I have a huge database (800MB) which consists of a field called 'Date Last
I have loaded an associative array of records from a MySQL database table. The
Got a question about Entity Framework and MyIsam tables. My production database consists of
I have a database that consists of 5 tables : Course, Category, Location, CourseCategories,
I am trying to retrieve values from the database using mysql and PHP. The

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.