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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:57:32+00:00 2026-06-14T12:57:32+00:00

I have this table: item year —- —- 1 1999 2 1999 3 1999

  • 0

I have this table:

item        year
----        ----
1           1999 
2           1999
3           1999 
2           2000 
4           2000 
2           2001
3           2001
4           2001
5           2001

And I need this result (with 1999 selected)

item        year
----        ----
4           2000
4           2001
5           2001

To sum up, I need to obtain new items which aren’t in 1999, but which are defined in another different year (this is for adding them with another query later).

I’m using an old MySQL version and I’m not able to use subqueries. Is there any compatible solution?

  • 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-14T12:57:33+00:00Added an answer on June 14, 2026 at 12:57 pm

    What about something like this

    SELECT t1.item, t1.year from table as t1
    LEFT JOIN table as t2 ON t2.item = t1.item AND t2.year = 1999
    WHERE t2.item IS NULL
    

    In “english” it means, select all the items from my table. Then for each item try to find if they are in the table with the year 1999, else put NULL.
    Then you just have to say “keep the elements that do not have a matching element in t2.

    Not sure if my explanation is better anyway

    EDIT: you of course need to replace table with the name of your own table. I tested it on a small example and it seems to work.

    EDIT2 : If you look at the result of the LEFT JOIN you would have something like this :

    t1.item     t1.year    t2.item     t2.year
    ----        ----       ----        ----       
    1           1999       1           1999
    2           1999       2           1999
    3           1999       3           1999
    2           2000       2           1999
    4           2000       NULL        NULL
    2           2001       2           1999
    3           2001       3           1999
    4           2001       NULL        NULL
    5           2001       NULL        NULL
    

    Then if you add WHERE t2.item IS NULL you only keep the ones not having a year 1999 in the table.
    Is it a better way to understand it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey all.i'm newbie at this problem.i have this data in table result: item range_code
I have a table with fields like this: Item Category Year Month Value I
So I have this table in my database Item Cat1 Cat2 -------------------- Aaa Red
i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table:
I have a bill of materials table that is set up like this: item
I try to have this computed column: CREATE TABLE dbo.Item ( ItemId int NOT
I have two tables like this:- TABLE A ITEM LOCATION CODE A WHS QW123
I have this table Test as Id, SomeValue, SomeText contains about a mill records,
I have this table: UNIQUE_ID | WINNER_ID | FINALIST_ID ________1 | ________1 | __________2
I have this table structure on a SQL Server 2008 R2 database: CREATE TABLE

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.