Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Temporary Table Help

Status
Not open for further replies.

dtfhome

Programmer
Oct 2, 2002
4
US
I have 3 tables which store the same types of information in three fields. Say for example, startdate - enddate - city.

Although the 3 have these fields in common, they are not directly related to each other in any other way.

I need to select the values from each of the three tables and then output all rows to a user (app server is coldfusion).
Example: Table 1 (cust) has 450 records.
Table 2 (pros) has 600 records.
Table 3 (comm) has 200 records.

I want to query for all three field values in each table, displaying a result of 1250 rows in three columns.

I am new with sql programming and think that a temporary table may be the way to go? If so, how would I create the table in a sql statement.

If not, what can I do?

Thanks in advance. Any suggestions appreciated.



 
use the UNION operator ( you can look it up in BOL for more details) ....

SELECT col1 as 'startdate', col2 as 'enddate', col3 as 'city'
from table1

UNION

SELECT col1 as 'startdate', col2 as 'enddate', col3 as 'city'
from table2

UNION

SELECT col1 as 'startdate', col2 as 'enddate', col3 as 'city'
from table3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top