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

UPDATE Query

Hi,

I have (amogst others) three tables in my database named Bookings, User, and
Representative. A User and a Representative are different types of user,
however I now want to merge these tables into one - User. When a Booking is
made, the User_ID and the Rep_ID are stored in the Booking table. I have now
merged the two tables (User and Representative), how can I update the Rep_ID
column in Bookings so that it refers to the User_ID for each Representative
in the User table?

Thanks for your help
Nov 12 '05 #1
2 9865
"Shaun" <re**********@mania.plus.com> wrote in
news:bj**********@reader-00.news.insnet.cw.net:
Hi,

I have (amogst others) three tables in my database named Bookings,
User, and Representative. A User and a Representative are different
types of user, however I now want to merge these tables into one -
User. When a Booking is made, the User_ID and the Rep_ID are stored in
the Booking table. I have now merged the two tables (User and
Representative), how can I update the Rep_ID column in Bookings so that
it refers to the User_ID for each Representative in the User table?

Thanks for your help


If you have kept your Representative table, and if there are field(s) that
you can use to relate Representative to User (such as a Name field), then
you can use:

UPDATE (Booking INNER JOIN Representative ON Booking.Rep_ID =
Representative.Rep_ID) INNER JOIN [User] ON Representative.Name = User.Name
SET Booking.Rep_ID = [User_ID];

hth
Richard
Nov 12 '05 #2
I don't know if this is possible unless you have the original tables. If you
do then I have a very uneligant solution for you, but it does mean that
there's no problems if people have say, the same name, or what ever.

First find the highest id in User, lets says it, 26, then change the type of
id in both the Representative table and the User table from autonumber to
number.

Then run this query on representative, replacing 26 with what ever number
you found earlier:
UPDATE Representative SET Representative.id = Representative.id+26;
and this one on the Bookings table, replacing 26 again:
UPDATE Bookings SET Bookings.rep_ID = Bookings.rep_ID+26;

Then copy the rows of the Represtative table and past them on the end of the
User table. Set the User tables id field back to autonumber and delete the
Representative table and your away.

Jamie

"Shaun" <re**********@mania.plus.com> wrote in message
news:bj**********@reader-00.news.insnet.cw.net...
Hi,

I have (amogst others) three tables in my database named Bookings, User, and Representative. A User and a Representative are different types of user,
however I now want to merge these tables into one - User. When a Booking is made, the User_ID and the Rep_ID are stored in the Booking table. I have now merged the two tables (User and Representative), how can I update the Rep_ID column in Bookings so that it refers to the User_ID for each Representative in the User table?

Thanks for your help

Nov 12 '05 #3

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

Similar topics

4
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
4
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code it might look like this: UPDATE tblAddress SET...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
7
by: Mark Carlyle via AccessMonster.com | last post by:
I have this update query that I am trying to run. I know the syntax is messed up but do not know how to correct it. Select 'UPDATE', Transactions,'Set = where = ' From "Get Daily Balances" ...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
31
by: Lag | last post by:
Having a problem updating my database from a web page, through a submission form. Can anyone help? ----THIS IS MY CODE IN update.php----(user, pass, and database are typed in directly, I...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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.