Query needed

S

subs

Table I

consignee dcity dstate dzip ocity ostate ozip
A d ak 560 b c 789
B e ck 869 de ef 970
C o lk 970 bh mk 975

table 2

consignee dcity dstate dzip ocity ostate ozip
A d ak 560 bl ct 7891
C o lk 970 bhe mtk 9751
F g mk 1075 hi lt 965

I have two tables as above. I need a query which can list all the
records from both the tables by combining the consignee, dcity, dstate
and dzip fields. I need the data in the following format---- Covering
all the records even if they are absent in one of the tables.------


table 1 table2
consignee dcity dstate dzip ocity ostate ozip ocity
ostate ozip
A d ak 560 b c
789 bl ct 7891
B e ck 869 de ef
970 - - -
C o lk 970 bh mk
975 bhe mtk 9751
F g mk
1075 hi lt
965


Pls help with query- i need the result in the above format.

Thanks much
 
J

John W. Vinson

Table I

consignee dcity dstate dzip ocity ostate ozip
A d ak 560 b c 789
B e ck 869 de ef 970
C o lk 970 bh mk 975

table 2

consignee dcity dstate dzip ocity ostate ozip
A d ak 560 bl ct 7891
C o lk 970 bhe mtk 9751
F g mk 1075 hi lt 965

I have two tables as above. I need a query which can list all the
records from both the tables by combining the consignee, dcity, dstate
and dzip fields. I need the data in the following format---- Covering
all the records even if they are absent in one of the tables.------


table 1 table2
consignee dcity dstate dzip ocity ostate ozip ocity
ostate ozip
A d ak 560 b c
789 bl ct 7891
B e ck 869 de ef
970 - - -
C o lk 970 bh mk
975 bhe mtk 9751
F g mk
1075 hi lt
965


Pls help with query- i need the result in the above format.


Word wrap has made a total hash of your desired output. Please repost it with
semicolons rather than tabs or blanks delmiiting the fieldnames and values -
as it is I can't make any sense of it.
 
V

vanderghast

That is the job of a full outer join, not directly supported by Jet. One
indirect way to solve it is :

Make a query which will return all the desired 'key' (once, no dup) , here,
something like:


SELECT consignee FROM table1
UNION
SELECT consignee FROM table2


Call this query q1.


Next, in a second query, bring q1, and table1. Link them with an outer join
(all rows from q1, matching ones from tabel1) over the common field
consignee.
Bring table2 to the query, also link q1 and table2 with an outer join (all
rows again from q1, matching ones from table2) again over their common
field, consignee.

In the grid, bring the required fields (consignee from q1, other fields from
table1 or table2, as you want them).


Vanderghast, Access MVP
 
R

Ram

That is the job of a full outer join, not directly supported by Jet. One
indirect way to solve it is :

Make a query which will return all the desired 'key' (once, no dup) , here,
something like:

SELECT consignee FROM table1
UNION
SELECT consignee FROM table2

Call this query q1.

Next, in a second query, bring q1, and table1. Link them with an outer join
(all rows from q1, matching ones from tabel1)  over the common field
consignee.
Bring table2 to the query, also link q1 and table2 with an outer join (all
rows again from q1, matching ones from table2) again over their common
field, consignee.

In the grid, bring the required fields (consignee from q1, other fields from
table1 or table2, as you want them).

Vanderghast, Access MVP

Whenever the consignee fields are common in both tables, and if i get
all the fields from both tables into the grid in the final query, i
get dcity, dstate, dzips repeated for that particular field(where
consignee fields are common). how to give dcity, dstate, dzip not
repeated in one row. pls help thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Query combining the tables 15
SQL 1
Pls help with SQL query 12
Query Help 2
Outlook crashes with Outlook connector 2002 0
Outlook connector crashes outlook 0

Top