473,699 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need to move column field values from one database table to another database table

This is what I tried:

Expand|Select|Wrap|Line Numbers
  1. update student_db.student set activities = (select i.activities from
  2. client.student c, student_db.student s where c.unique_key =
  3. s.unique_key);
  4. ERROR 1093 (HY000): You can't specify target table 'student' for update
  5. in FROM clause
  6. mysql>
  7.  
I just need to move all of the contents in client.student. activities to
student_db.stud ent.activities, how do I do that?

Thanx
Phil

Jan 27 '06 #1
2 3327
<ph************ **@gmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I just need to move all of the contents in client.student. activities to
student_db.stud ent.activities, how do I do that?


MySQL versions 4.0 and later support an extension to SQL called multi-table
updates. You can do something analogous to a join, in an update statement.
This is not standard SQL, but imho it is so useful and sensible that it
should be!

Something like this should work (but I haven't tested it):

UPDATE student_db.stud ent, client.student
SET student_db.stud ent.activities = client.student. activities
WHERE student_db.stud ent.unique_key = client.student. unique_key

See http://dev.mysql.com/doc/refman/5.0/en/update.html for more info.

Regards,
Bill K.
Jan 27 '06 #2
That was perfect! I have never heard of this before, but thanx!

Phil

Bill Karwin wrote:
<ph************ **@gmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I just need to move all of the contents in client.student. activities to
student_db.stud ent.activities, how do I do that?


MySQL versions 4.0 and later support an extension to SQL called multi-table
updates. You can do something analogous to a join, in an update statement.
This is not standard SQL, but imho it is so useful and sensible that it
should be!

Something like this should work (but I haven't tested it):

UPDATE student_db.stud ent, client.student
SET student_db.stud ent.activities = client.student. activities
WHERE student_db.stud ent.unique_key = client.student. unique_key

See http://dev.mysql.com/doc/refman/5.0/en/update.html for more info.

Regards,
Bill K.


Jan 27 '06 #3

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

Similar topics

3
3161
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and populate a combo box with these names. (this way, I can display all the EMPLOYEE_NAME values) (2) In general, can I do additional processing on column values from
3
10651
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
5
11791
by: Tim | last post by:
Hi, I am trying to move a datacolumn in a datatable. What I have tried so far is to create a new datacolumn set it equal to the one I want to remove and then remove it, add another column and add it back again in the place I want it. tableStyle.MappingName = "DVGlobalPrices"; System.Data.DataColumn dCol = new DataColumn();
2
1491
by: phillip.s.powell | last post by:
I have to migrate data from one database table to another table in another database where the fields do not match, not even in the same order, and even if they do match, on occasions the datatypes are completely different (varchar vs int, varchar vs char, int vs datetime, etc.). I am expected to do this immediately so this is an emergency request. Help!
7
2944
by: am72de | last post by:
Hi all, I've posted this problem some weeks ago, but noone had a solution. Perhaps now someone could help me. I have the following tables: Create Table T1 ( ID1 int Not Null , ID2 int Not Null
0
1423
by: EiEiO | last post by:
Hello all. I am hoping I could get some suggestions on moving forward. My Challenge: Importing data from one table to another where the field names almost never match. My Form has a list box, (this is the FROM table), that lists tables in the currentDb. Also, multiple comboboxes to and to .
2
4718
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First question. I have a web survey that I am working on and have successfully dynamically taken the info from a database, displayed it on the screen and then taken the users answers and inserted them into a
3
1881
by: Eric | last post by:
When i run my query it transfer last 4 digits of account number from one table to another and its wrong. There are two tables one i use for parsing. Second thru query i use to move data from temp table to actual table with some little changes in temp table. I use the same code in two different databases One database works fine and another database wont move the account number with 9 digit size. Difference is only the structre of text files...
11
4490
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
0
8618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9178
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.