I have two tables, they contain:
Table1: ID1, Name1, Address1, Purchase1
Table2: ID2, Name2, Address2, Purchase2
I need a query which creates Table3 with content from Table1 and Table2.
The records in Table3 have to contain all distinct records from Table1 and
Table2 (records where Name2 and Address2 do not already exist in Table3) and
Any help appreciated. I need these queries as a reference, I consider they
are a starting point in building other queries.
Regards,
Nicolae 7 3764
Here are a number of SQL statements that you can paste into queries to
achieve this.
The way to paste them is to create a new query then goto SQL view and paste
it in there. Make sure you get it right, otherwise you will have to close
the query without saving.
Alternatively, you can always type SELECT * from [tbln];
where tbln is a name of table in your database
here we go:
1. SELECT [table1].ID1 AS ID, [table1].name1 AS name, [table1].address1 AS
address, [table1].purchase1 AS purchase FROM [table1];
save this query as T1
2.SELECT [table2].ID2 AS ID, [table2].name2 AS name, [table2].address2 AS
address, [table2].purchase2 AS purchase FROM [table2];
save this query as T2
3. select [T1].* from [T1] UNIION SELECT [t2].* FROM [T2]
save this query as T3
4. SELECT name, address, purchase FROM [t3]
GROUP BY name, address, purchase;
save this query as T3_unique
I have broken down the steps, so that you adjust each part as required.
If I am unclear, please ask and i will explain.
Nicolaas
PS the idea is to give the names of the fields in T1 and T2 the same names,
then UNION them. That is, merge them. Next you select each unique name,
address, purchase (did you want to include this???) combination.
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net... I have two tables, they contain:
Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2
I need a query which creates Table3 with content from Table1 and Table2. The records in Table3 have to contain all distinct records from Table1 and Table2 (records where Name2 and Address2 do not already exist in Table3)
and Any help appreciated. I need these queries as a reference, I consider they are a starting point in building other queries.
Regards, Nicolae
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.698 / Virus Database: 455 - Release Date: 02/06/2004
Hi,
Thank you very much. Your explanation was very clear and it showed me that
instead of using a complex query, I can use a few simple queries to achieve
my task. I will test your code later.
Regards,
Nicolae
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:ZW******************@news.xtra.co.nz... Here are a number of SQL statements that you can paste into queries to achieve this.
The way to paste them is to create a new query then goto SQL view and
paste it in there. Make sure you get it right, otherwise you will have to close the query without saving.
Alternatively, you can always type SELECT * from [tbln];
where tbln is a name of table in your database
here we go:
1. SELECT [table1].ID1 AS ID, [table1].name1 AS name, [table1].address1 AS address, [table1].purchase1 AS purchase FROM [table1];
save this query as T1
2.SELECT [table2].ID2 AS ID, [table2].name2 AS name, [table2].address2 AS address, [table2].purchase2 AS purchase FROM [table2];
save this query as T2
3. select [T1].* from [T1] UNIION SELECT [t2].* FROM [T2]
save this query as T3
4. SELECT name, address, purchase FROM [t3] GROUP BY name, address, purchase;
save this query as T3_unique
I have broken down the steps, so that you adjust each part as required.
If I am unclear, please ask and i will explain.
Nicolaas PS the idea is to give the names of the fields in T1 and T2 the same
names, then UNION them. That is, merge them. Next you select each unique name, address, purchase (did you want to include this???) combination. "Nicolae Fieraru" <no****@please.cxm> wrote in message news:40********@duster.adelaide.on.net... I have two tables, they contain:
Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2
I need a query which creates Table3 with content from Table1 and Table2. The records in Table3 have to contain all distinct records from Table1
and Table2 (records where Name2 and Address2 do not already exist in Table3) and Any help appreciated. I need these queries as a reference, I consider
they are a starting point in building other queries.
Regards, Nicolae
--- Please immediately let us know (by phone or return email) if (a) this
email contains a virus (b) you are not the intended recipient (c) you consider this email to be spam. We have done our utmost to make sure that none of the above are applicable. THANK YOU Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.698 / Virus Database: 455 - Release Date: 02/06/2004
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net... I have two tables, they contain:
Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2
I need a query which creates Table3 with content from Table1 and Table2. The records in Table3 have to contain all distinct records from Table1 and Table2 (records where Name2 and Address2 do not already exist in Table3)
and
select Name1, Address1 into Table3
from
(
select Name1, Address1
from Table1
union
select Name2, Address2
from Table2
)
Hi John,
Thank you again for your support. Unfortunately this query doesn't work. It
sais there is an error in from clause. I am able to use the clause as a
query in its own, I don't know why it doesn't work all together
Regards,
Nicolae
"John Winterbottom" <as******@hotmail.com> wrote in message
news:2i************@uni-berlin.de... "Nicolae Fieraru" <no****@please.cxm> wrote in message news:40********@duster.adelaide.on.net... I have two tables, they contain:
Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2
I need a query which creates Table3 with content from Table1 and Table2. The records in Table3 have to contain all distinct records from Table1
and Table2 (records where Name2 and Address2 do not already exist in Table3) and
select Name1, Address1 into Table3 from ( select Name1, Address1 from Table1 union select Name2, Address2 from Table2 )
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net... Hi John,
Thank you again for your support. Unfortunately this query doesn't work.
It sais there is an error in from clause. I am able to use the clause as a query in its own, I don't know why it doesn't work all together
What version of Access are you using?
Hi John,
I am using Office 97. I checked now the query on a system with Office2002
and it worked
Is there a way to build that query for Office97?
Regards,
Nicolae
"John Winterbottom" <as******@hotmail.com> wrote in message
news:2j************@uni-berlin.de... "Nicolae Fieraru" <no****@please.cxm> wrote in message news:40********@duster.adelaide.on.net... Hi John,
Thank you again for your support. Unfortunately this query doesn't
work. It sais there is an error in from clause. I am able to use the clause as a query in its own, I don't know why it doesn't work all together
What version of Access are you using?
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net... Hi John,
I am using Office 97. I checked now the query on a system with Office2002 and it worked Is there a way to build that query for Office97?
Regards, Nicolae
I think you'll have to do it in two stages.
1. create the union query.
2. create a second query using the insert into clause (a "make table" query
in Access-speak), using the first query as the sorce for the select. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: toedipper |
last post by:
Hello,
I am designing a table of vehicle types, nothing special, just a list of
unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor
etc etc
For the table design I am...
|
by: Ed_No_Spam_Please_Weber |
last post by:
Hello All & Thanks in advance for your help!
Background:
1) tblT_Documents is the primary parent transaction table that has 10
fields and about 250,000 rows
2) There are 9 child tables with...
|
by: Dan |
last post by:
Hi, just ran into my first instance of a backend Access97 database not
compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on
compact.
I've narrowed it down to the largest...
|
by: ms |
last post by:
Access 2000:
I am trying to delete duplicate records imported to a staging table leaving one
of the duplicates to be imported into the live table. A unique record is based
on a composite key of 3...
|
by: Tom Esker |
last post by:
I have three linked tables that I can update individually but when I
put them together into a query, I can no longer update the data. The
tables are tied together with a field called "CASEID"...
|
by: Michael C via AccessMonster.com |
last post by:
Hello,
I have a table that I am appending 3 seperate tables into. My main problem
is that each time I append the data, it simply adds to the data already there.
That might sound ok, except that...
|
by: p175 |
last post by:
Hi people,
I have a stored procedure that creates many Global temporary
session tables. Into each of these tables go the results of various
processing using relational division all keyed and...
|
by: Ian Boyd |
last post by:
Every time during development we had to make table changes, we use Control
Center. Most of the time, Control Center fails. If you try to "undo all", it
doesn't, and you end up losing your identity...
|
by: melchior |
last post by:
Hi,
I have searched and searched without much luck. I feel like I am doing the right thing, just not getting the right result, so here goes.
I have 2 tables. One has about 100,000 records...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |