Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

SQL HALP Exists/Not Exists

DeebaserDeebaser Way out in the waterSee it swimmin'?Registered User regular
Please help H/A. My code isn't working and I'm having a bit of a brainfart. Here's what I am trying to do:


I want to identify all the SOMETHING_NUMs that we have from an external feed that don't have corresponding object_ids on our internal table. object_ids are a 9 character string in the middle of SOMETHING_NUM.

What am I fucking up?


SELECT DISTINCT
SOMETHING_NUM
FROM
database..external_feed
WHERE
NOT EXISTS
(SELECT *
FROM db2..internal_tbl1 di,
database..external_feed
where
SUBSTRING(SOMETHING_NUM,3,9) = di.object_id)

#FreeThan
#FreeScheck
#FreeSKFM

Posts

  • bowenbowen Registered User regular
    Try:
    SELECT DISTINCT SOMETHING_NUM 
    FROM database..external_feed 
    WHERE NOT EXISTS
      ( SELECT * FROM db2..internal_tbl1, di, database..external_feed di.object_id = (SUBSTRING(SOMETHING_NUM,3,9)))
    

    If that doesn't work, what error do you get?

    bowen on
  • DeebaserDeebaser Way out in the water See it swimmin'?Registered User regular
    There's no error message. There's just no population. I know that there is a population because I did a run without the NOT EXISTS for a small sample date range.

    The problem is, I can't run the full history like that because it's pretty resource hoggy.

    @Bowen

    #FreeThan
    #FreeScheck
    #FreeSKFM
  • DeebaserDeebaser Way out in the water See it swimmin'?Registered User regular
    Got it. Thanks Bowen!

    Please lock.

    #FreeThan
    #FreeScheck
    #FreeSKFM
  • bowenbowen Registered User regular
    Sybase, fun!

Sign In or Register to comment.