House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Search sql

July 04, 2009

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Home / Groups / SQL

Conditional join

Author:
Ian Skinner
09/17/2007 06:29 PM

I have an pretty ugly join to make.  I need to join parts of a varchar in one table to separate fields in the second.  I can do this part ok, but the kicker that has me stumped is that one apart is optional.  This is against an Oracle 8 dbms. Here is the code I am using to break up and cast the parts of the varchar field in the pur table and match it to fields in the pro table.   But the forth part should only happen if that part of the varchar string is NOT a zero.  Is there some way to make this part of the join conditional?     cast(substr(pur.epa_registration_num,0,7) AS number(7)) = pro.mfg_firmno AND     cast(substr(pur.epa_registration_num,8,5) AS number(5)) = pro.label_seq_no AND     cast(substr(pur.epa_registration_num,13,2) AS char(2)) = pro.revision_no AND     cast(substr(pur.epa_registration_num,15,7) AS number(7)) = pro.reg_firmno


Mailing Lists