Update field through relationship? - mysql
This is a discussion on Update field through relationship? - mysql ; I have a two-table relationship and I want to get rid of one table. I have a table of surveys, where each row is related to one row in a table of access codes. These are the relevant fields: Surveys.access_code_id ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| I have a table of surveys, where each row is related to one row in a table of access codes. These are the relevant fields: Surveys.access_code_id AccessCodes.id AccessCode.valid_date We are moving to a new method of access validation, so we don't need the table of AccessCodes anymore. I want to add the field Surveys.valid_date, and update the value with the appropriate value from the AccessCodes table, before I delete it. So I want to do something like UPDATE Surveys SET Surveys.valid_date = SELECT valid_date FROM AccessCodes WHERE AccessCodes.id = Surveys.access_code_id Is this the proper syntax? I'm hesitant to play around with UPDATE queries! ![]() |
|
#2
| |||
| |||
|
On Nov 14, 12:52*pm, lawpoop > > So I want to do something like > > UPDATE Surveys SET Surveys.valid_date = SELECT valid_date FROM > AccessCodes WHERE AccessCodes.id = Surveys.access_code_id > > Is this the proper syntax? I'm hesitant to play around with UPDATE > queries! ![]() I did some testing with some test tables, and this works: UPDATE Surveys SET survey_date = ( SELECT `date` FROM AccessCodes WHERE AccessCodes.id = Surveys.access_code_id ); ![]() |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 05:06 AM.





Linear Mode