473,546 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Results in Parallel columns

Hi ,

I need to place the results of two different queries in the same result
table parallel to each other.
So if the result of the first query is

1 12
2 34
3 45

and the second query is

1 34
2 44
3 98

the results should be displayed as

1 12 34
2 34 44
3 45 98

If a union is done for both the queries , we get the results in rows.
How can the above be done.

Thanks in advance,
vivekian

Jun 14 '06 #1
7 1685

vivekian wrote:
Hi ,

I need to place the results of two different queries in the same result
table parallel to each other.
So if the result of the first query is

1 12
2 34
3 45

and the second query is

1 34
2 44
3 98

the results should be displayed as

1 12 34
2 34 44
3 45 98

SELECT qry1.fld1 As FirstField, qry1.fld2 As SecondField, qry2.fild2 as
ThirdField
FROM qry1 INNER JOIN qry2 ON qry1.Field1=qry 2.fld1
ORDER BY FirstField

Jun 14 '06 #2
On 14 Jun 2006 14:26:00 -0700, "vivekian" <vi*********@gm ail.com>
wrote:
I need to place the results of two different queries in the same result
table parallel to each other.
So if the result of the first query is

1 12
2 34
3 45
select ... into cursor one
and the second query is

1 34
2 44
3 98
select ... into cursor two
the results should be displayed as

1 12 34
2 34 44
3 45 98
select one.*,two.*
from one full outer join two on one.pk=two.pk
with suitable changes for DBMS and table and column names.
If a union is done for both the queries , we get the results in rows.
How can the above be done.


Sincerely,

Gene Wirchenko

Jun 14 '06 #3
CREATE TABLE #a (Idx INT NOT NULL PRIMARY KEY,
Val INT NOT NULL)

CREATE TABLE #b (Idx INT NOT NULL PRIMARY KEY,
Val INT NOT NULL)

INSERT INTO #a (Idx, Val)
SELECT 1, 12
UNION SELECT 2, 34
UNION SELECT 3, 45

INSERT INTO #b (Idx, Val)
SELECT 1, 34
UNION SELECT 2, 44
UNION SELECT 3, 98

SELECT a.Idx, a.Val, b.Val
FROM #a a
INNER JOIN #b b
ON a.Idx = b.Idx
ORDER BY a.Idx

DROP TABLE #a
DROP TABLE #b

"vivekian" <vi*********@gm ail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Hi ,

I need to place the results of two different queries in the same result
table parallel to each other.
So if the result of the first query is

1 12
2 34
3 45

and the second query is

1 34
2 44
3 98

the results should be displayed as

1 12 34
2 34 44
3 45 98

If a union is done for both the queries , we get the results in rows.
How can the above be done.

Thanks in advance,
vivekian

Jun 14 '06 #4
If I understand the question, my vote goes to Piet's solution. If you have
unmatched rows in either Query, then you'd need something a bit different.

Larry Linson
Microsoft Access MVP

"vivekian" <vi*********@gm ail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Hi ,

I need to place the results of two different queries in the same result
table parallel to each other.
So if the result of the first query is

1 12
2 34
3 45

and the second query is

1 34
2 44
3 98

the results should be displayed as

1 12 34
2 34 44
3 45 98

If a union is done for both the queries , we get the results in rows.
How can the above be done.

Thanks in advance,
vivekian

Jun 15 '06 #5
Hang on a minute... I guess my answer was a bit premature before. What
database are you using to do this? If you're using Oracle, you can use
a full outer join and PL/SQL to do it.

If you're using Access, it's a different kettle of fish, because Access
doesn't support full outer joins.

So end the suspense. What database are you doing this in? (Or just
target your post to the relevant database group). The answer will
largely depend on that, since Oracle, Access, SQL Server, and DB2 all
have their own implementations of the SQL92 standard...

Jun 15 '06 #6

pi********@hotm ail.com wrote:
Hang on a minute... I guess my answer was a bit premature before. What
database are you using to do this?


using SQL Server

thanks,
vivekian

Jun 15 '06 #7
>>I need to place the results of two different queries in the same result table parallel to each other. <<

This is not a table; the rows of a table model elements of a set of the
same kind of thing. What you want is a display kludge to show, say,
automobiles and squid as if they were the same kind of things.

Here is your kludge, since people here often gripe that I do not post
the bad code the OP wants:

SELECT *, ROW_NUMBER() OVER(ORDER BY duh) AS lft_nbr
FROM Foo
FULL OUTER JOIN
SELECT *, ROW_NUMBER() OVER(ORDER BY doh) AS rgt_nbr
FROM Bar
ON Foo.lft_nbr = Bar.rgt_nbr;

The right way is handle display issues in the applications and front
ends, not the RDBMS.

Jun 15 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3531
by: Don | last post by:
I am new to Indexing Services, have been researching the MS Site as well as web articles on DevHood, etc. I have set up a seperate catalog ("KnowledgeBase") on Win XP with a number of files. I am trying to use OLEDB through ADO to search results and serve them up onto an ASP.Net web page, yet I consistently get back 0 results. I have this...
4
5017
by: Haydnw | last post by:
Hi, I'd like to put a load of database results (several rows for 5 fields) into a two-dimensional array. Now, this may be a really stupid question, but can someone give me a pointer for how to do it? I can bind data to datagrids and lists and stuff all day long, but can't seem to grasp this one. Any pointers to a useful article / demo (or...
11
10458
by: lovecreatesbeauty | last post by:
For example, line L1 and line L2 are two lines in two-dimensional space, the start-points and end-points can be described with following the `point_t' type. The start-points and end-points are: Line L1 (L1_str, L1_end), L2 (L2_str, L2_end). Can I compare the float value of sloping rate of two lines to determine whether they are parallel...
7
1464
by: vivekian | last post by:
Hi , I need to place the results of two different queries in the same result table parallel to each other. So if the result of the first query is 1 12 2 34 3 45
74
4508
by: aruna.mysore | last post by:
Hi all, I have a simple definitioin in a C file something like this. main() { char a; ....... int k; }
21
3678
by: bruno_guedesav | last post by:
I've made a function to fetch all results as an array of result- arrays. Getting the result arrays is easy, via mysql_fetch_array, and function itself is quite simple, as follows: function db_query($db, $query) { $result = mysql_query($query, $db); $res_array = array(); if ($result) //it is a search
4
15287
by: Soren | last post by:
Hi, I want to control some motors using the parallel port.. however, my laptop does not have any parallel ports (very few do). What I do have is a USB->Parallel converter... I thought about using PyParallel, but the USB->Parallel converter doesn't actually map to the LPT port .. and PyParallel only looks for LPT ports? Has anyone...
3
2827
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one dataset to data in a second dataset, using a common key. I will first describe the problem in words and then I will show my code, which has most of the...
2
1091
by: Senjalia | last post by:
Hi, Please help me with SQL code that would do Union of two query results NOT having same columns. For example, first result returns columns A,B,C and D and second result returns columns A,B and C. I do not want rows with duplicate values for A, B and C columns. Result 1: A B C D 1 2 3 4 1 3 4 5 Result 2:...
0
7504
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7792
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.