On Thu, Jul 26, 2001 at 11:43:05PM -0500, Ben Luey wrote:
> Hey all -- thanks for the php help -- I've got it all working now. But
> I've got a mysql question:
> 
> I want to append two select results to eachother. Is there a good way to
> do this (ie, not: make temp table, insert select1 into temp_table, select2
> into temp table.)
> 
> I've got two tables
> 
> ID	Last	A
> 1	Smith	some
> 2	Kim	one
> 
> 
> ID2	Last	B
> 1	Fred	other
> 2	Barg	than
> 
> 
> and I want to get outputed:
> 
> ID	ID2 	Last	A	B
> 1		Smith	some
> 2		Kim	one
> 	1	Fred		other
> 	2	Barg		than
> 
> 
> Basically, I want to the two tables merged together, but I want no overlap
> -- the join command seems to work for joining two table containing linked
> information, but I've got different entries in two types of tables. (The
> purpose of this is so I can sorta on Last between the two tables)
> 
> Any ideas?

I don't know if mysql supports UNION, but the big databases do:

union
	(select ID, Last, A, NULL, NULL, NULL from Table1)
	(select NULL, NULL, NULL, ID2, Last, B from Table2)
	
Or if you want
 ID    Last    something
 1     Smith   some
 2     Kim     one
 1     Fred    other
 2     Barg    than

use
	union
		(select ID, Last, A something from Table1)
		(select ID2 ID, Last, B something from Table2)
	
florin

-- 

"If it's not broken, is because you are not fixing it enough."

41A9 2BDE 8E11 F1C5 87A6  03EE 34B3 E075 3B90 DFE4