MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 17th, 2000, 06:47 PM
hotatom hotatom is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 18 hotatom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm trying to make a MySQL query through PHP to update a field in one table with the value in another table.

The query i've been trying (and doesn't work) is:

UPDATE tableA,tableB SET tableA.fieldA=tableB.fieldB WHERE tableA.idA=tableB.idB AND tableA.dateA<55555

I'm trying to set fieldA in tableA to equal fieldB in tableB for each of the rows where dateA in tableA is < 55555. I'm linking the two tables with the idA and idB fields.

Any idea how to do this?

Reply With Quote
  #2  
Old September 20th, 2000, 01:23 AM
Niclas Bengtsson Niclas Bengtsson is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Sweden
Posts: 61 Niclas Bengtsson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 32 m 35 sec
Reputation Power: 9
As far as Iīve heard, this canīt be done in MySQL with the UPDATE command.

Reply With Quote
  #3  
Old September 21st, 2000, 07:12 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 21 h 11 m 18 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
I seem to remember hearing that somewhere too. It may depend on your version, though, so just try the update command like you said and see if it works. If it doesn't, and you have the latest stable version, then your only option will be multiple commands, select then update...

---JH

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Updating fields from one table to another in a single statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT