Re: Union query and exclusion of data



Hi Syed,

I am sure you are explaining in mathematically accurate
terms, but I regretably must be in some fog today...

Is there a chance you could give some example data
for A.x and B.x, then result from that data that you want
including which table final value comes from?

sorry...my old reliable computer went down
Friday and am using old noisy (jet-engine) server
while I try to revive old faithful -- so noise and frustrations
are getting in way of understanding...(I'm sure its not
old brain..hah)

gary

"Syed Zeeshan Haider" wrote:
Thank you for your response. This query included data only from B when it
was shared by both tables. I am trying to exclude and include A in the
given
case.

Thanks again for your time!

"Gary Walter" <gary@xxxxxxxxxxx> wrote in message
news:exRB5AekIHA.4244@xxxxxxxxxxxxxxxxxxxxxxx

"Syed Zeeshan Haider"wrot:
I am usin Access 2003 Pro and trying to create a rather complex union
query
but don't seem to implement conditions.

Let's say I have two tables called A and B. A has column called x and B
also
has a column called x. I am trying to join these two columns into one
column
with following conditions:
If e is a member of both A and B then the query should include e from
table
A only (because the second column calculates a value which depends on
the
choice of table for picking e). I have tried all INNER JOIN, LEFT JOIN
and
RIGHT JOIN but none of them have worked so far.

Here is an example of what I did:

select [A].[x]
FROM [A] INNER JOIN [B] ON [A].[x] = [B].[x]
where (([A].[x]) Is Not Null) and (([A].[x])<>([B].[x]))
UNION select [B].[x]
from [B];

Any ideas what am I doing wrong here?
Any help will be highly appreciated.

Thank you,
--
Syed Zeeshan Haider



Hi Syed,

It sure sounds like you want
(just threw in "FromTable" to verify)

SELECT
"A" As FromTable,
A.x As WantValue
FROM A
UNION
SELECT
"B",
B.x
FROM
B LEFT JOIN A
ON
B.x = A.x
WHERE
A.x IS NULL
ORDER BY
WantValue,
FromTable;

the first select gets all A.x...

the last select gets all of B
except where value of B.x in A.x...

good luck,

gary






.



Relevant Pages

  • Combining feilds
    ... Is it possible to combine data from multiple feild of same table into one ... feild of query? ... Syed Zeeshan Haider ...
    (microsoft.public.access.queries)
  • Re: Union query and exclusion of data
    ... "Syed Zeeshan Haider"wrot: ... If e is a member of both A and B then the query should include e from ... A.x As WantValue ... good luck, ...
    (microsoft.public.access.queries)
  • Re: Progress Bar
    ... (remove nothere from the email address if mailing direct) ... "Syed Zeeshan Haider" wrote in message ...
    (microsoft.public.excel.programming)
  • Re: Union query and exclusion of data
    ... Thank you for your response. ... This query included data only from B when it ... I am trying to exclude and include A in the given ... "Syed Zeeshan Haider"wrot: ...
    (microsoft.public.access.queries)