473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

More Queries...

Hi All,

I have two tables, they contain:

Table1: ID1, Name1, Address1, Purchase1
Table2: ID2, Name2, Address2, Purchase2

I need a query which will show ID1, ID2, Name1, Address1 from Table1 and
Table2 which have the same name and address (Name1 = Name2 and Address1 =
Address2)

I also need a query which should add to Table1 all records from Table2, but
only for new Customers (Name2 and Address2 should not be present in the same
record in Table1)

Any help appreciated.

Regards,
Nicolae
Nov 13 '05 #1
2 1102
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40******@duster.adelaide.on.net...
Hi All,

I have two tables, they contain:

Table1: ID1, Name1, Address1, Purchase1
Table2: ID2, Name2, Address2, Purchase2

I need a query which will show ID1, ID2, Name1, Address1 from Table1 and
Table2 which have the same name and address (Name1 = Name2 and Address1 =
Address2)
select t1.ID1, t2.ID2, t1.Name1, t1.Address1
from Table1 as t1 inner join Table2 as t2
on t1.Name1 = t2.Name2
and t1.Address1 = t2.Address2

I also need a query which should add to Table1 all records from Table2, but only for new Customers (Name2 and Address2 should not be present in the same record in Table1)


assuming ID is an automumber column:

insert into Table1(Name1, Address1, Purchase1)
select t2.Name2, t2.Address2, t2.Purchase2
from Table2 as t2
where not exists
(
select * from Table1 as t1
where t1.Name1 = t2.Name2
and t1.Address1 = t2.Address2
)
Nov 13 '05 #2
Thank you very much John, they work like a charm :-)


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roger Green | last post by:
I have inherited a complex database that has many dozens of queries that derive data from a people table. I now need to be able to run these queries (from within a significant number of forms)...
4
by: Koen | last post by:
Hi all, At work I created a database which is really helpful. The database is used by approx 15 users. Everything worked great, until I added some 'scoreboard' forms and reports. I get the...
3
by: NeilAnderson | last post by:
I'm a fairly new user of access & I've never had any training, so I'm wondering if I'm doing the right thing here, or if it matter at all. I'm building a database for room booking purposes and I'm...
4
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not...
12
by: Susan Bricker | last post by:
For those of you who have been following my posts - they all pertain to a Dog Competition Organization's Database. There are three classes that the dogs can participate: NOVICE, OPEN, and...
4
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is...
44
by: Greg Strong | last post by:
Hello All, Is it better to create a query in DAO where a report has 4 sub-reports each of whose record source is a query created at runtime and everything is in 1 MDB file? From what I've...
2
by: garethfx | last post by:
Hi all Anybody had experience bring together 2 or more crosstab queries using the UNION? ALL 3 crosstabs come from 3 sourcing queries from the same table so of course normally runnning 3...
6
by: =?Utf-8?B?Q3JhaWc=?= | last post by:
If I have an application that I send out to users, and the application interacts with the database (behind the scenes, no direct sql creation by the users)....do webservices make the app more...
2
n8kindt
by: n8kindt | last post by:
i'm stuck. i'm using access 2007 on a windows vista machine (i've tried running on xp too, though--same result) and this is the error i keep getting whenever i try running my main query: Cannot...
0
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,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.