The problem is a little abstract, but I agree that a UNION is the way to go.
If it's possible that there are rows in table 2 that do not have keys that
match table 1, then you'd want a join (or equivalent) in the second part of
the union.

Something like this:

select jobID, description
from table1
union
select t2.jobID, t2.description
from table2 t2
inner join table1 t1 on t2.jobid = t1.jobid

This gives you everything in table1, plus everything in table2 that has a
key that also exists in table1.

If you want to preserve potentially identical rows in your output, make it
UNION ALL instead of UNION.

  -- Ken

On 10/9/06, Ian Skinner <[EMAIL PROTECTED]> wrote:
>
> So, if there is a JobID = 1 in Table1 and 2 JobID = 1 in Table2, I need 3
> rows.  The one from Table1 and the 2 from Table2
>
> I'm having a hard time even explaining this, so hopefully this makes some
> sense.
>
> Well there are two possible solutions to this depending on what you really
> need.
>
> The first, more common, solution is an join.  You would join the two
> tables with a join and this would get you two rows each with the id from one
> table and an id from the second table.  You would use an inner or outer join
> depending on how you want to handle records that do not have IDs in both
> tables.
>
> The second, if you really need these as separate records, is a union.  You
> would write one select clause and union it to a second select clause.  This
> would give you a record set with three records each with an id from either
> table one or table two.
>
>
>
>
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
>
> ---------
> | 1 |   |
> ---------  Binary Soduko
> |   |   |
> ---------
>
> "C code. C code run. Run code run. Please!"
> - Cynthia Dunning
>
> Confidentiality Notice:  This message including any
> attachments is for the sole use of the intended
> recipient(s) and may contain confidential and privileged
> information. Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the
> intended recipient, please contact the sender and
> delete any copies of this message.
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2575
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6

Reply via email to