473,383 Members | 1,877 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,383 software developers and data experts.

Need help with insert query ?

Deear All,
I would be thankful if you could help me with the following query.

I have two tables TableA and TableB

TableA
Name: David
Address: 123 West Side
City: New York

TableB
Name: David
Address: 123 West Side
Profession: Engineer

I need to Insert the data from TableB to TableA if the Address matches

I want to get rid of TableB so I want to merge the data from second and add a
Profession in Table A

So after merging the Table A would be

TableA
Name: David
Address: 123 West Side
City: New York
Profession: Engineer

I would appreciate your help and Thanks in Advance

Nick
Nov 12 '05 #1
1 2164
The BIG problem is that you need a way to identify which record in TableA to add
Engineer to! If you go solely on Name, there may be records in TableA that have
the same name but not necessarily duplicates. The best you're going to do is to
use both the Name and Address fields and making the assumption (keeping in mind
the definition of what assumption is) that for the same person, his Name and
Address is entered in to both tables EXACTLY the same way. Given this
ass-umption, create a new field in TableA called Profession. Next include both
tables in a query. Join the Name fields in both tables and join the Address
fields in both tables. Pull down the Profession field from TableA. Change the
query to an Update Query by clicking on the query type button in the toolbar at
the top of the screen. In the query grid where it says Update To under
Profession put:
TableB.Profession.

Click on the red exclamation point in the toolbar at the top of the screen and
depending on the validity of your assumption you will get what you want.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com
"Nick" <n.******@verizon.net> wrote in message
news:d6**************************@posting.google.c om...
Deear All,
I would be thankful if you could help me with the following query.

I have two tables TableA and TableB

TableA
Name: David
Address: 123 West Side
City: New York

TableB
Name: David
Address: 123 West Side
Profession: Engineer

I need to Insert the data from TableB to TableA if the Address matches

I want to get rid of TableB so I want to merge the data from second and add a
Profession in Table A

So after merging the Table A would be

TableA
Name: David
Address: 123 West Side
City: New York
Profession: Engineer

I would appreciate your help and Thanks in Advance

Nick

Nov 12 '05 #2

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

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
5
by: Juho Saarikko | last post by:
I made a Python script which takes Usenet message bodies from a database, decodes uuencoded contents and inserts them as Large Object into a PostGreSQL database. However, it appears that the to...
2
by: Philip Hachey | last post by:
I think this is do-able, and possibly even simple, but it's been too many years since I've done anything significant with SQL. Any help would be appreciated. I have two tables, PAY and CHG. ...
4
by: soni29 | last post by:
hi, i need some help with a query, also to find out if this is even possible with sql. currently i have a table with the following data: CustomerNumber CustomerBranch 123 NULL 123 1...
3
by: FRITSCH Vincent | last post by:
Hi, i need help on a query. I've this table : create table t ( customer number(5), time date, status varchar2(1)
1
by: Jimmy Tran | last post by:
Hi All, I have a table below and I want to design a query to pull all the members from the TABLE into a Query Result and into a single column with points assigned appropriately, but I am having...
3
by: AMD Desktop | last post by:
Here is the table: CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NOT NULL , NOT NULL , NOT NULL CONSTRAINT DEFAULT (0), NOT NULL , NOT NULL ) ON
6
by: Toucan | last post by:
i need to retrieve the most recent timestamped records with unique names (see working query below) what i'm having trouble with is returning the next-most-recent records (records w/ id 1 and 3...
21
by: tizmagik | last post by:
Database consists of the following 4 tables with respective attributes: CUSTOMER(C#, CUSTOMER NAME, ADDRESS), the key is ITEM(I#, ITEM NAME, MANUFACTURER, YEAR), the key is BOUGHT(C#, I#,...
4
by: CK | last post by:
Good Morning All, Can use use a variable for the FOR clause in a cursor? Example I have DECLARE @a varchar(50), @b varchar(50), @c varchar(50) DECLARE @sql varchar(255) DECLARE @x...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
BarryA
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.