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

  • Thread starter Thread starter Ajith Nair
  • Start date Start date
A

Ajith Nair

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
 
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
 
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;
 
Back
Top