Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 10th, 2004, 04:40 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old February 10th, 2004, 02:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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.
Reply With Quote
  #3 (permalink)  
Old February 11th, 2004, 03:48 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
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


Reply With Quote
  #4 (permalink)  
Old February 11th, 2004, 08:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
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
Reply With Quote
  #5 (permalink)  
Old February 12th, 2004, 04:27 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
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=

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:34 PM.


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