Expert Answer Center > Experts On Demand > View Answer
EMAIL THIS
Experts on Demand
  EXPERTS ON DEMAND HOME     POSE A QUESTION     VIEW ANSWERS     BROWSE BY TOPIC        RSS FEEDS  
My question concerns mainframe DB2 utilities. How can I use the data from one DB2 table to determine which rows to unload from another DB2 table? An example would be one table contains a list of zip codes and the streets within each zip code. The other table contains all the homeowners and their street names. I only want the homeowners for a particular list of zip codes so that I can create a table on another platform with a specific subset of homeowners. I would prefer to use utilities rather than write multiple programs, if possible. QUESTION POSED ON: 19 JUL 2005
QUESTION ANSWERED BY: Rudy Limeback Do you really want utilities? In SQL, the results you describe can be produced by a join. Hopefully, mainframe DB2 has some facility that will allow you to submit the SQL to select the results want and then feed those results to some output file so you can use it on your other platform.

The SQL you would use looks something like this:

select h.name 
     , h.street_number 
     , h.street_name 
     , h.city 
     , h.zipcode 
  from zipcodes as z 
inner 
  join homeowners as h 
    on z.street_name = h.street_name 
   and z.zipcode = h.zipcode 
 where z.zipcode in ( '12345', '34567', '90210' )
Here the values in the WHERE clause select the zip codes you want, and then every street in each of those zip codes is compared to the homeowners' addresses, and all matching homeowners are returned. Note that the join is on two columns, because it's possible to have the same street name in more than one zip code.
HomeExperts on DemandIT Expert Webcast SeriesExpert KnowledgebaseSite Index
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts