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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:26:52+00:00 2026-05-27T18:26:52+00:00

I have a table in SQlite that I’m using to cache some data. I’m

  • 0

I have a table in SQlite that I’m using to cache some data. I’m totally hung up on writing an SQL query that when given a list of x strings will return a subset y that are not in the table. I understand I could just query one by one and check for an empty result but I’d like to know if there’s a way to do this that returns a nice, neat list of the strings not cached (not in the table).

FWIW I’m using sqlite3 and Python. The query I’ve got so far is something like

select e from cache where cache.fk = x and e in (a, b, c);

which is close but gives the opposite behavior from what I want (it returns values that would be a cache hit).

I also understand that in this case it is slightly inappropriate to use a relational database over a key/value store but even if I were to switch away I’m still interested in seeing how this would be done.

  • 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-27T18:26:52+00:00Added an answer on May 27, 2026 at 6:26 pm

    Assuming there’s a set value of things you’re caching and that they come from a table, use not exists:

    select 
        v.e 
    from
        vals v 
    where 
        v.fk = x
        and v.e in (a,b,c)
        and not exists (
            select
                1
            from
                cache c
            where
                c.fk = v.fk
                and c.e = v.e
        )
    

    If you don’t have a table of available values and are just throwing some set back, you’d go with a dynamic table, like this:

    select 
        v.e 
    from
        (
        select a as e
        union all
        select b as e
        union all
        select c as e
        ) v 
    where 
        not exists (
            select
                1
            from
                cache c
            where
                c.fk = x
                and c.e = v.e
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sqlite table that has amount field with NUMERIC(10,5) value(I know data
I have a table that stores date/time values as julian days in SQLite (using
I have data in an SQLite table that looks like this: user_id event_date ----------
I have an SQLite table that contains a BLOB I need to do a
I have a database/table in SQLITE using the following structure CREATE TABLE milestones (
So I'm writing an application in C# using SQLITE that will keep track of
I have a very large CSV file that I imported into a sqlite table.
Given that I have a table with a column of TEXT in it (MySQL
I have a sqlite table that was originally created with: PRIMARY KEY (`column`); I
I have a Sqlite database that has a table consisting of company information (Companies)

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.