• 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
    Computer Keyes

    Fax Directly from your IBM i

    KeyesFax is a full function automated IBM i fax system. Spooled files are burst by fax number and auto transmitted with overlays.  It combines both a send and receive facsimile processing system with a complete image package.

    The fax software will edit, send, receive, display, print, and track fax documents or images using any standard IBM i without additional expensive hardware, software or subscriptions.

    Computer Keyes has been developing Software Solutions since 1978!

    www.computerkeyes.com

    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

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25

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