PC Review


Reply
Thread Tools Rate Thread

how can I join two querys --- to be precise

 
 
Ajith Nair
Guest
Posts: n/a
 
      7th Sep 2006
Hi,

I have a query called A which is

select id,custID from A1;

and second query B which is,

select id,CustId from A2;

I want to join this both query and get the result together.

B Regards
Ajith

 
Reply With Quote
 
 
 
 
Albert D. Kallal
Guest
Posts: n/a
 
      7th Sep 2006
Just open up the query builder, and jump to sql view.

Paste in your two quires with a "union all" command like

select id,custID from A1;

union all

select id,CustId from A2;

Ok, now save the query. The resulting query can be used for reports, or
even exporting


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      7th Sep 2006
Sorry, Albert, but that won't work: you've included an unnecessary
semi-colon in the first subselect.

SELECT id, CustId FROM A1
UNION ALL
SELECT id, CustId FROM A2;

Note that if the same id occurs in both A1 and A2, it'll show up twice in
that query. If you only want it to show up once, use

SELECT id, CustId FROM A1
UNION
SELECT id,CustId FROM A2;

If the same id occurs in both, but different CustID values are associated
with them, they'll still both appear.

If you have a need to keep track of which table each record came from, use

SELECT id, CustId, "A1" AS Source FROM A1
UNION ALL
SELECT id, CustId, "A2" AS Source FROM A2;

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Albert D. Kallal" <(E-Mail Removed)> wrote in message
news:O6%23K%(E-Mail Removed)...
> Just open up the query builder, and jump to sql view.
>
> Paste in your two quires with a "union all" command like
>
> select id,custID from A1;
>
> union all
>
> select id,CustId from A2;
>
> Ok, now save the query. The resulting query can be used for reports, or
> even exporting
>
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> (E-Mail Removed)
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Try to be more precise Mel Microsoft Excel Discussion 4 8th Mar 2009 03:17 PM
vlookup not precise enough davegb Microsoft Excel Discussion 4 23rd Oct 2007 02:49 PM
Querys based on Querys =?Utf-8?B?R2lsbA==?= Microsoft Access Queries 7 2nd Sep 2007 07:27 PM
how can I join two querys Ajith Nair Microsoft Access 1 7th Sep 2006 05:10 PM
Sub: finding a precise value monika Microsoft Excel Misc 4 11th Feb 2004 03:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 PM.