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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:31:32+00:00 2026-06-03T04:31:32+00:00

I have a rather confusing SQLite query that I can’t seem to quite wrap

  • 0

I have a rather confusing SQLite query that I can’t seem to quite wrap my brain around.

I have the following four tables:

Table “S”

sID (string/guid)  | sNum (integer)
-----------------------------------
aaa-aaa                   1
bbb-bbb                   2
ccc-ccc                   3
ddd-ddd                   4
eee-eee                   5
fff-fff                   6
ggg-ggg                   7

Table “T”

tID (string/guid) | ... other stuff
-----------------------------------
000
www
xxx
yyy
zzz

Table “S2TMap”

sID    |    tID
-------------------
aaa-aaa    000
bbb-bbb    000
ccc-ccc    xxx
ddd-ddd    yyy
eee-eee    www
fff-fff    000
ggg-ggg    000

Table “temp”

oldID (string/guid) | newID (string/guid)
------------------------------------------
   dont care          fff-fff
   dont care          ggg-ggg
   dont care          zzz

What I need is to be able to get the MAX() sNum that exists in a specified “t” if the sID doesn’t exist in the temp.NewID table.

For example, given the T ‘000’, ‘000’ has S ‘aaa-aaa’, ‘bbb-bbb’, ‘fff-fff’, and ‘ggg-ggg’ mapped to it. However, both ‘fff-fff’ and ‘ggg-ggg’ exist in the TEMP table, which means I need to only look at ‘aaa-aaa’ and ‘bbb-bbb’. Thus, the statement would return “2”.


How would I go about doing this?

I was thinking something along the lines of the following for selecting s that don’t exist in the “temp” table, but I’m not sure how to get the max of the seat and only do it based on a specific ‘t’

SELECT s.sID, s.sNum FROM s WHERE NOT EXISTS ( SELECT newID from temp where tmp.newID = s.sID)

Thanks!

  • 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-03T04:31:34+00:00Added an answer on June 3, 2026 at 4:31 am

    Give this a try:

    select max(s.sNum) result from s2tmap st
    join s on st.sId = s.sId
    where st.tId = '000' and not exists (
      select * from temp
      where temp.newId = st.sId)
    

    Here is the fiddle to play with.

    Another option, probably less efficient would be:

    select max(s.sNum) result from s2tmap st
    join s on st.sId = s.sId
    where st.tId = '000' and st.sId not in (
      select newId from temp)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am stuck with rather confusing query. Assume I have a ProductLending table that
I have a rather huge query that is needed in several stored procedures, and
I have a rather confusing setup for a program that lets the user choose
I right now have a problem that is rather confusing to me: I have
I have rather large project that uses ICU regex classes. Basically it might run
Have a rather simple question. Does anyone knows if i can use jparallax both
I have a rather complicated deploy setup for our Drupal site that is a
I have a rather large database that has alot of decimal columns in alot
I have a rather confusing problem in running our game. I am trying to
I have a rather confusing issue. I've recently picked up some code I wrote

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.