Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2004, 04:40 AM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Columns below each other

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

 
Old February 10th, 2004, 02:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
 
Old February 11th, 2004, 03:48 AM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old February 11th, 2004, 08:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

The UNION statement works by combining the results of two or more queries:
Code:
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
 
Old February 12th, 2004, 04:27 AM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help. And regarding UNION statement i found a useful link, too:

http://webapp.progress.com:6336/dyna...ART_N%25;book=






Similar Threads
Thread Thread Starter Forum Replies Last Post
two columns if... gabster XSLT 0 August 15th, 2007 12:21 PM
Columns in Datagrid monika.vasvani ASP.NET 1.0 and 1.1 Professional 2 December 3rd, 2006 11:26 AM
sub columns preethisg BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 0 December 27th, 2005 01:53 AM
Listview columns Duncan VS.NET 2002/2003 0 April 16th, 2004 03:00 AM
Columns in reports Clive Astley Access 3 April 8th, 2004 07:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.