![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a large (9000 records) table 'map', with a key field 'id', and a data field 'p'. I have a small (30 records) table 'hexads', with a unique field 'rm0', whose value matches one of the 'id' values in 'map', and a currently empty field 'p03' which I want to put data in. What I want to do is for each record of 'hexads' look up its 'rm0' value in the 'id' field of 'map' take the 'p' value from that record of 'map' and put it in the 'p03' field of the record of 'hexads' How can I do this in MySQL? Nick |
#3
| |||
| |||
|
|
On 14-10-10 21:23, Nick Wedd wrote: I have a large (9000 records) table 'map', with a key field 'id', and a data field 'p'. I have a small (30 records) table 'hexads', with a unique field 'rm0', whose value matches one of the 'id' values in 'map', and a currently empty field 'p03' which I want to put data in. What I want to do is for each record of 'hexads' look up its 'rm0' value in the 'id' field of 'map' take the 'p' value from that record of 'map' and put it in the 'p03' field of the record of 'hexads' How can I do this in MySQL? Nick update hexads H set H.p03=(SELECT M.p from map M where M.id=H.rm0 LIMIT 1) |
|
But a better answer might be found at: http://dev.mysql.com/doc/refman/5.1/en/update.html |
#4
| |||
| |||
|
|
I have a large (9000 records) table 'map', with a key field 'id', and a data field 'p'. I have a small (30 records) table 'hexads', with a unique field 'rm0', whose value matches one of the 'id' values in 'map', and a currently empty field 'p03' which I want to put data in. What I want to do is for each record of 'hexads' look up its 'rm0' value in the 'id' field of 'map' take the 'p' value from that record of 'map' and put it in the 'p03' field of the record of 'hexads' How can I do this in MySQL? |
#5
| |||
| |||
|
|
I have a large (9000 records) table 'map', with a key field 'id', and a data field 'p'. I have a small (30 records) table 'hexads', with a unique field 'rm0', whose value matches one of the 'id' values in 'map', and a currently empty field 'p03' which I want to put data in. |
#6
| |||
| |||
|
|
In article<fUnU4CCLj1tMFAh+@maproom.demon.co.uk>, Nick Wedd<nick (AT) maproom (DOT) co.uk> wrote: I have a large (9000 records) table 'map', with a key field 'id', and a data field 'p'. I have a small (30 records) table 'hexads', with a unique field 'rm0', whose value matches one of the 'id' values in 'map', and a currently empty field 'p03' which I want to put data in. What I want to do is for each record of 'hexads' look up its 'rm0' value in the 'id' field of 'map' take the 'p' value from that record of 'map' and put it in the 'p03' field of the record of 'hexads' How can I do this in MySQL? The following would work in Access; I don't know if MySQL supports the same syntax: UPDATE hexads INNER JOIN map ON map.id = hexads.rm0 SET hexads.p03 = map.p ; |
![]() |
| Thread Tools | |
| Display Modes | |
| |