|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
As far as Iīve heard, this canīt be done in MySQL with the UPDATE command.
|
|
#3
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Updating fields from one table to another in a single statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|