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 January 17th, 2008, 09:05 AM
Registered User
Join Date: Jan 2008
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?

Old January 17th, 2008, 09:10 AM
Friend of Wrox
Join Date: Jun 2003
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:
================================================== =========
Old January 21st, 2008, 08:15 AM
Friend of Wrox
Join Date: Oct 2007
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

Old March 6th, 2008, 03:43 AM
Registered User
Join Date: Mar 2007
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

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

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