Is it possible to create a union query that contains criteria from another union query?
I would like the query to only display the order numbers from TeamUnions that are either contained in FromMortASA and FromMortO.
Is that possible?
---
SELECT [order_num], [employee_id], [from_order_step_num], [to_order_step_num], [move_time], [from_step_duration_sec]
FROM [dbo_FromMortO]
WHERE [order_num]=[TeamUnions].[order_number]
UNION
SELECT [order_num],[employee_id], [from_order_step_num], [to_order_step_num], [move_time], [from_step_duration_sec]
FROM [dbo_FromMortAsA]
WHERE [order_num]=[TeamUnions].[order_number];
---
?? I'm sure that is wrong.
5 2569
Hi, there.
Did you try this or read Access help topic "UNION operation"
By default, no duplicate records are returned when you use a UNION operation; however, you can include the ALL predicate to ensure that all records are returned.
Hi, there.
Did you try this or read Access help topic "UNION operation"
Yes I have done both. What i'm trying to accomplish is to only Union the data from 2 tables that match the Order numbers from another Union Query.
Hi, there.
Make joins and union them. Like this. -
SELECT [dbo_FromMortO].[order_num], [dbo_FromMortO].[employee_id], [dbo_FromMortO].[from_order_step_num], [dbo_FromMortO].[to_order_step_num], [dbo_FromMortO].[move_time], [dbo_FromMortO].[from_step_duration_sec]
-
FROM [dbo_FromMortO] INNER JOIN [TeamUnions] ON
-
WHERE [dbo_FromMortO].[order_num]=[TeamUnions].[order_number]
-
UNION
-
SELECT [dbo_FromMortAsA].[order_num], [dbo_FromMortAsA].[employee_id], [dbo_FromMortAsA].[from_order_step_num], [dbo_FromMortAsA].[to_order_step_num], [dbo_FromMortAsA].[move_time], [dbo_FromMortAsA].[from_step_duration_sec]
-
FROM [dbo_FromMortAsA] INNER JOIN [TeamUnions] ON
-
WHERE [dbo_FromMortAsA].[order_num]=[TeamUnions].[order_number];
-
Hi, there.
Make joins and union them. Like this.
Thanksf or the tip. I ended up getting it to work:
SELECT dbo_FromMortO.order_num, dbo_FromMortO.employee_id, dbo_FromMortO.from_order_step_num, dbo_FromMortO.to_order_step_num, dbo_FromMortO.move_time, dbo_FromMortO.from_step_duration_sec
FROM dbo_FromMortO INNER JOIN TeamUnions ON dbo_FromMortO.order_num=TeamUnions.order_number
WHERE dbo_FromMortO.order_num=TeamUnions.order_number;
UNION SELECT dbo_FromMortAsA.order_num, dbo_FromMortAsa.employee_id, dbo_FromMortAsa.from_order_step_num, dbo_FromMortAsa.to_order_step_num, dbo_FromMortAsA.move_time, dbo_FromMortAsA.from_step_duration_sec
FROM dbo_FromMortAsA INNER JOIN TeamUnions ON dbo_FromMortAsA.order_num=TeamUnions.order_number
WHERE dbo_FromMortAsA.order_num=TeamUnions.order_number;
You are welcome.
Best regards,
Fish
Sign in to post your reply or Sign up for a free account.
Similar topics
by: s_gregory |
last post by:
The mdb is considerable size 70 +- mb. A complex union query was
working well, but when an additional union select... was added into
the query, selecting identical fields from a different source,...
|
by: Salad |
last post by:
A97.
Situation: I have 3 tables with a text field in each and a date field
in the first 2 tables:
Table1 Text1, Date1
Table2 Text2, Date2
Table3 Text3 (no date field)
The following...
|
by: Alicia |
last post by:
Hello everyone based on the data, I created a union query which
produces this.
SELECT ,,, 0 As ClosedCount
FROM
UNION SELECT
,, 0 AS OpenedCount,
FROM
ORDER BY , ;
|
by: NoodNutt |
last post by:
G'day ppl.
Can anyone assist me with the correct structure of the following in a Union
Query.
tblBookings.FinYear
tblBookings.DepPrefPay
tblBookings.IntPrefPay
tblBookingsFinPrefPay
|
by: KoliPoki |
last post by:
Hello every body.
I have a small issue.
Problem: I have a table with 4 descriptor columns (type). I need to
formulate a query to retrieve a count for each type so I can group
by...etc. The...
|
by: MLH |
last post by:
I have a saved UNION query named
qryAuthsOwnersAddnlOwnersLienholders4OneCar.
Here it is...
SELECT & " " & & " " &
& " " & & ", " & & "
" & & " " & "(" & & " county) " &...
|
by: ebasshead |
last post by:
Hi Everyone
I have four queries that Ive joined in a union query and want to add a date criteria ei between and including date A and date B. Ive tried a few things but getting errors. Can someone...
|
by: MLH |
last post by:
Consider having tblCorrespondence, then copying & pasting
it to tblCorrespondence1 - such that they are identical. Then
consider the following UNION SELECT statement...
SELECT...
|
by: jmarcrum |
last post by:
Hi!
I have created a Union Query in ACCESS 2003, that combines 130 records from one query (Extra Foreman Radios) and 250 records from another query (Forman Main Radios). I have created a...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |