Solved

join multiple query results into 1 query

Posted on 2014-02-05
7
240 Views
Last Modified: 2014-02-06
hey guys, i have 3 complex queries and they each give me just 1 value

so for example

Query 1: Output result --> 137
Query 2: Output result --> 33
Query 3: Output result --> 104

there is only 1 cell for each of the output results

Question: how do i join these into 1 resultant queries with 3 cells in 1 row?

i was thinking of using a union query but i don't think that will work as i am trying to add columns instead of rows

i was thinking about outer join but i don't have a unique key

the only way i can think of so far is to write it to a temporary table and then do a select query from there.

thanks in advance guys!
0
Comment
Question by:developingprogrammer
  • 3
  • 3
7 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 39838031
Hello developingprogrammer,

In my opinion, a union query will suffice with your requirement. You can design it using a sample below:


SELECT DISTINCT tblSample.TestField
FROM tblSample
WHERE (((tblSample.TestField)="Emp1"))

UNION ALL

SELECT DISTINCT tblSample.TestField
FROM tblSample
WHERE (((tblSample.TestField)="Emp2"))

UNION ALL

SELECT DISTINCT tblSample.TestField
FROM tblSample
WHERE (((tblSample.TestField)="Emp3"));


Sincerely,

Ed
0
 

Author Comment

by:developingprogrammer
ID: 39838082
hi Ed, thanks for your response!

so the result would be 1 column with 3 rows is that correct?

let's say just for moot i really need 3 columns in 1 row, how can i achieve that? thanks! = )
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 39838097
Just ignore my post:

"as i am trying to add columns instead of rows"

I missed that part in your question.

Sincerely,

Ed
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 19

Accepted Solution

by:
MINDSUPERB earned 250 total points
ID: 39838104
You can create a Crosstab out from the union query.

Ed
0
 

Author Comment

by:developingprogrammer
ID: 39838110
whao i didn't think of that. ok i need to go and read up on crosstab queries. good idea, thanks Ed!
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 39838479
Actually, you could simply try:

Select qry1.Field1, qry2.Field1, qry3.Field1
FROM qry1, qry2, qry3

This is a Cartesian join, all combinations of all records from all queries.
0
 

Author Comment

by:developingprogrammer
ID: 39840875
whao Dale, that is a fantastic idea! i really like your idea and i also really like Ed's idea. they both serve different purposes and in this case both work. thanks so much for chipping in Dale! = )
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question