PDA

View Full Version : 2 Tables as 1


dswimboy
04-08-2004, 08:12 AM
I have two tables. Both contain StartDate and EndDate Date fields. Table one contains line1 and line2 Text fields. Table 2 contains host and location text fields.

i would like to return 1 table, composed of the combination of the two tables above.

raf
04-08-2004, 09:06 AM
You could join the two tables, but do you have any fields in it to join them ?

dswimboy
04-08-2004, 06:36 PM
I am having trouble understanding the JOIN usage. let me explain myself more, since i don't think it's what i want.

Table1
+-----------+---------+-------+-------+
| StartDate | EndDate | line1 | line2 |
+-----------+---------+-------+-------+
| 02-25-86 | 02-26-86| blah | blah |
+-----------+---------+-------+-------+
| 05-12-86 | 05-19-86| blah | blah |
+-----------+---------+-------+-------+

Table 2
+-----------+---------+------+-----+
| StartDate | EndDate | Type | Host| other fields....
+-----------+---------+------+-----+
| 02-25-86 | 02-26-86| AB | Here|
+-----------+---------+------+-----+
| 05-12-86 | 05-19-86| DC |There|
+-----------+---------+------+-----+

I would like to return this:
+----------+---------+------+------+
| StartDate| EndDate | line1| line2|
+----------+---------+------+------+
| 02-25-86 | 02-26-86| blah | blah |
+----------+---------+------+------+
| 05-12-86 | 05-19-86| blah | blah |
+----------+---------+------+------+
| 02-25-86 | 02-26-86| AB | Here |
+----------+---------+------+------+
| 05-12-86 | 05-19-86| DC |There |
+----------+---------+------+------+

raf
04-08-2004, 06:58 PM
So just append the recordsets? --> if so, then look into UNION

(SELECT StartDate, EndDate, line1, line2 FROM Table1) UNION (SELECT StartDate, EndDate, Type, Host FROM Table2)

dswimboy
04-08-2004, 07:14 PM
works great! thanks