Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 17th, 2008, 09:05 AM
Registered User
Join Date: Jan 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Put together 2 selects results in a single one

I have 2 queries that I need to show in a report.
I am using a limited and poor report generator, so what I want is put together(in a sigle query) the results of the 2 queries
on the way bellow:

Select field1, field2
from tab1

select field3, field4
from tab2

O resultado desejado seria

field1 | field2 | field3 | field4

Look, there is no key to make a relation between the two selects or anything else,
I just want to concat the results.
Can anyone help me?

Reply With Quote
  #2 (permalink)  
Old January 17th, 2008, 09:10 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

hi there..

what logic do you want to use to concat the results is there is no key?



================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
================================================== =========
I know that CVS was evil, and now i got the proof:
================================================== =========
Reply With Quote
  #3 (permalink)  
Old January 21st, 2008, 08:15 AM
Friend of Wrox
Join Date: Oct 2007
Location: , , .
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi

Select field1, field2, field3, field4

from tab1
cross join tab2

where field1=???
and field2=???.......

here where part is optional, result will be every row of tab1 with every row of tab2

Reply With Quote
  #4 (permalink)  
Old March 6th, 2008, 03:43 AM
Registered User
Join Date: Mar 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

i think u need to use Union Operator

SELECT field1, field2, '' AS field3, '' AS field4
FROM tab1
SELECT '' AS field1, '' AS field2, field3, field4
FROM tab2

to use the union, u need the same no. of columns to combine.

hope it'll solve me. correct me if i'm wrong

Reply With Quote

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
How to combine two value-of selects? myhtpc XSLT 2 February 14th, 2006 06:20 AM
multiple selects -single where clause collie SQL Server 2000 3 January 21st, 2005 01:27 AM
ASP.Net Single Single-on with Oracle Application S guhanath Oracle 0 October 6th, 2004 05:05 AM
Trying to send SQL results to a single variable NathanielMc VB Databases Basics 9 June 3rd, 2004 02:36 PM
Two selects in one procedure Trojan_uk SQL Server 2000 2 December 17th, 2003 05:28 AM

All times are GMT -4. The time now is 05:23 AM.

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