• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

EXISTS/UNION Combination

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
select
t1.ACCT_ID
from
account t1,
where exists
(select t2.ACCT_ID
from
exempt_account t2
where
t2.CTF_ENTY_ID = ?
and t2.EXMPT_STRT_DT = ?
and t2.EXMPT_END_DT = ?)
order by t1.ACCT_ID asc;

Problem:
I have to extract recs from exempt_account table by matching the enty_id from the enty_id that's passed in (refer to ? above) + comparing Strt_dt + End_dt dates to dates I passed in (refer to ? above).
If there is a match I then want to use enty_id to match to a rec on the account table where I capture the acct_id.
If there is no match to the exempt_account table I want to use the enty_id
that's passed in and match directly to the account table.
If rec exists in exempt_account table it's considered to be 'exempt' and I need to be able to create a field that I can later test to determine if it came from exempt_account table or just account table.
If it only exists in account table It's non-exempt.
 
Rocko Smith
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should I use a union for the 2 tables because this only works if there is a record in the exempt_account table?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic