Running a search to identify member
<p>I'm essentially trying to join single records in <code>tableA</code> based on information in <code>tableB</code>. If I get more than one result with the original joining conditions then I add more and rerun the query. If I get no results, then nothing transfers. ex: Search for <code>a.FRST_NM = b.FRST_NM</code>. If one result, pull the record. If more than one, add <code>LAST_NM</code> and if one result, pull that record. So on and so forth until I have one record. I can do one at a time, but this occurs 2 or 3 times per pass.</p>

<p>This is because some fields aren't populated in one table but are in the other. I just don't know how to add joining conditions without rewriting the entire <code>FROM</code> statement, or how to only pull the record if there's only one result. </p>

<pre><code>IF(CONDITION_1 from JOIN_1) = 1 result THEN a.field_1 = b.field_1 and a.field_2 = b.field_2 

IF (CONDITION_1 from JOIN_1) &gt; 1 result THEN (additional joining conditions + JOIN_1) as JOIN_1a 

ELSE IF(CONDITION_1 from JOIN_1a) = 1 result then a.field_1 = b.field_1 and    a.field_2 = b.field_2

IF(CONDITION_1 from JOIN_1) = 0 results then NO MOVE

--(Repeat with different tables and joining conditions)--
</code></pre>