• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Joining on Mismatched Values

    June 13, 2007 Hey, Ted

    Like many shops, we have a mixture of database files that we have acquired from different sources due to mergers and acquisitions over the years. Getting things to match up is challenging, to put it mildly. I have two files that contain warehouse code fields, but the codes do not match exactly. In one file, a certain warehouse is indicated by the letter T. In the other file, the same warehouse is the character 1 (one). All other warehouses have the same codes in both files.

    I need to join these files, but I don’t know what to do about the warehouse with different codes. I thought of setting up a cross-reference file, but wondered if there is any way to avoid it. A cross-reference file would be yet another file to maintain when we add new warehouses. Is there a way to tell SQL that T in one file matches 1 in the other file?

    –CS

    My gut feeling is that the warehouse cross-reference file is probably your best way to go, unless you have only one program that needs to carry out such a join. Anyway, you’ll have to be the judge of that.

    If you want to avoid the cross reference, use a CASE statement in your join. Here’s an example that uses two files, XACT and MASTER. Warehouse T in XACT is warehouse 1 in MASTER.

    SELECT xact.KEY, xact.whs, mast.WhsID, mast.WhsName 
      FROM xact AS xact 
      LEFT JOIN master AS mast 
        ON CASE 
             WHEN xact.whs = 'T' 
               THEN '1' 
               ELSE xact.whs 
            END = mast.WhsID
    

    The CASE converts T to 1, but leaves other warehouse codes as they are. The value from the CASE is compared to the WhsID field in the MASTER file.

    –Ted



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    New Generation Software

    FREE Webinar:

    Creating Great Data for Enterprise AI

    Enterprise AI relies on many data sources and types, but every AI project needs a data quality, governance, and security plan.

    Wherever and however you want to analyze your data, adopting modern ETL and BI software like NGS-IQ is a great way to support your effort.

    Webinar: June 26, 2025

    RSVP today.

    www.ngsi.com – 800-824-1220

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Midrange Alliance:  Free Gartner Whitepaper on massive iSeries modernization project
    Help/Systems:  SEQUEL is the single solution for all your business intelligence needs
    COMMON:  Join us at the Annual 2008 conference, March 30 - April 3, in Nashville, Tennessee

    IT Jungle Store Top Book Picks

    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket Developers' Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    iSeries Express Web Implementer's Guide: List Price, $59.00
    Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    WebFacing Application Design and Development Guide: List Price, $55.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    The All-Everything Machine: List Price, $29.95
    Chip Wars: List Price, $29.95

    Infinite Software to Participate in Aberdeen Report The i5 515 and 525 Versus the Unix Competition

    Leave a Reply Cancel reply

Volume 7, Number 22 -- June 13, 2007
THIS ISSUE SPONSORED BY:

Midrange Alliance
Vision Solutions
WorksRight Software

Table of Contents

  • Fix Decimal Data Errors
  • Joining on Mismatched Values
  • Admin Alert: Alternative Ways to Print PC5250 Screens

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle