|
Subject:
|
Columns below each other
|
|
Posted By:
|
pontitt2
|
Post Date:
|
2/10/2004 3:40:29 AM
|
Hi!
Could somebody help me how to put two columns below each other in one query (so you have two database and you would like to put them into one database, in which database the records of the sorce databases are below each other).
Thanks:
pontitt
|
|
Reply By:
|
bmains
|
Reply Date:
|
2/10/2004 1:50:40 PM
|
If I understand the question correctly, you could use a UNION statement, which you would select the column for the first database and then select the second database's column.
|
|
Reply By:
|
pontitt2
|
Reply Date:
|
2/11/2004 2:48:35 AM
|
Thank you for your help. But then what should be the SQL statement?
SELECT UNION(Name, Name_1) FROM...
or
UNION (Name, Name_1) FROM...
Because these are not working, as I tried.
I would like to do the following: 1st database (in a separate file): Name Date Price($) Jonas January 10 Evelin February9
2nd database (in an another separate file): Name_2 Date_2 Price($)_2 Maria June 7 Anna August 2
And the result (after a query): Name_3 Date_3 Price($)_3 Jonas January 10 Evelin February9 Maria June 7 Anna August 2
So the records (and the columns) are under each other.
pontitt
|
|
Reply By:
|
Jeff Mason
|
Reply Date:
|
2/11/2004 7:02:59 AM
|
The UNION statement works by combining the results of two or more queries:
SELECT col1, col2, ...
FROM ...
UNION
SELECT col3, col4, ...
FROM ...
Getting the queries to refer to tables in different databases may be problematic, depending on your RDMS. In SQL Server it's pretty easy if the two databases are on the same server; in that case the table names are given in the format <database.owner.tablename>, etc.
Jeff Mason Custom Apps, Inc. www.custom-apps.com
|
|
Reply By:
|
pontitt2
|
Reply Date:
|
2/12/2004 3:27:31 AM
|
Thank you for your help. And regarding UNION statement i found a useful link, too:
http://webapp.progress.com:6336/dynaweb/psdoc91d/sqloa91d/s89/@ebt-link;cs=default;ts=default;pt=14847;lang=hu?target=%25N%15_16373_START_RESTART_N%25;book=
|