Multiple Queries into One Query with seperate fields

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I have tried and failed to find a solution to this. I am trying to create a Query that shows one Field from multiple Queries. I do not want to use Union as this will create one Field, each result must have its own Field. The Fields do not have common information.

Any help would be much appreciated. Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
maybe ...
Code:
select 
  table_1.field_1 as [field 1], 
  null as [field 2]
from 
  table_1
  
union all 
  
select 
  null as [field 1], 
  table_2.field_2 as [field 2]
from 
  table_2
 
Upvote 0
Thanks James,

That is so close. My only problem now (if its possible) is to have all returned data at the top of each Field and how to add new Fields. Thanks, very much appreciated.
 
Upvote 0
That is so close. My only problem now (if its possible) is to have all returned data at the top of each Field and how to add new Fields. Thanks, very much appreciated.
What exactly does your data look like?
I suspect that you may have a design flaw in your table structure, which is making things harder than they have to be.

How many tables and fields are we talking about?
Does each table have more than one record?
Can you post some sample data?, and your expected results?
 
Upvote 0
Hi, Due to the nature of the data, I'm afraid I cannot post a sample. But I can tell you what I'm trying to achieve.

I have a Table with multiple fields , one of them being a 'Site Name' and one being a 'Group Name'. (Every 'Site' belongs to a 'Group'). What I need to create is a Query that splits out the 'Group Names' into Fields with each Field being populated with the 'Site Names'. I will then link this Query into Excel where I use each Group in dropdowns etc.

To try to achieve this, I created a Query for each 'Group Name' and populated it with the 'Site Names'. I was then trying to combine them into one Query.

Even as I write this, it seams very amateurish. Which I am. I hope I've explained well enough.

Thanks
 
Upvote 0
so each Site can belong to only one group ?

but a group can have multiple sites in it ?

so its like Cities and States ?
each City can only belong in one state, but a state can have multiple cities ?
 
Upvote 0
Yes, each site can only belong to one group.

Each group can have multiple sites.

Exactly, Cities and States is a perfect example.

Thanks
 
Upvote 0

Forum statistics

Threads
1,221,622
Messages
6,160,887
Members
451,676
Latest member
Assy Bissy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top