chewbears Posted March 15, 2011 Share Posted March 15, 2011 I have this query to convert file paths to image directory paths and Degree's minutes seconds to Decimal Degrees. "select *, concat('mywebsitehere',path) as URL, (substr(EXIF_lat,1, locate('° ', EXIF_lat) - 1) + substr(EXIF_lat,locate('° ', EXIF_lat) + 7, locate('\'', EXIF_lat) - 1)/60 + substr(EXIF_lat,locate('\'', EXIF_lat) + 2,locate('\"', EXIF_lat) - 1)/3600) as Latitude, concat('-',(substr(EXIF_long,1,locate('° ', EXIF_long) - 1) + substr(EXIF_long, locate('° ',EXIF_long) + 7, locate('\'', EXIF_long) - 1)/60 + substr(EXIF_long, locate('\'', EXIF_long) + 2, locate('\"', EXIF_long) - 1)/3600)) as Longitude from plogger_pictures where EXIF_lat is not null and EXIF_long is not null;" I want it to automatically do it whenever a record is added to the table. So basically Latitude, Longitude, URL, would be autocreated and populated when a record is added. How do I make this code, either all together or in pieces work to achieve my goal? Thanks Link to comment https://forums.phpfreaks.com/topic/230724-auto-update-columns/ Share on other sites More sharing options...
fenway Posted March 15, 2011 Share Posted March 15, 2011 Not sure I understand -- you want the update syntax, or a trigger? Link to comment https://forums.phpfreaks.com/topic/230724-auto-update-columns/#findComment-1187913 Share on other sites More sharing options...
chewbears Posted March 15, 2011 Author Share Posted March 15, 2011 I want a trigger because currently I have it running in a cron, so every night at mid night I populate the old fields with the new fields using these lines. Update TABLE_NAME_HERE SET Lat_DD = (substr(EXIF_lat,1, locate('° ', EXIF_lat) - 1) + substr(EXIF_lat,locate('° ', EXIF_lat) + 7, locate('\'', EXIF_lat) - 1)/60 + substr(EXIF_lat,locate('\'', EXIF_lat) + 2,locate('\"', EXIF_lat) - 1)/3600) Was just wondering if there is a way to make the above happen on its own whenever a record is say added to the database. Link to comment https://forums.phpfreaks.com/topic/230724-auto-update-columns/#findComment-1187920 Share on other sites More sharing options...
chewbears Posted March 16, 2011 Author Share Posted March 16, 2011 Where is the trigger stored? Not really understanding the syntax http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html Link to comment https://forums.phpfreaks.com/topic/230724-auto-update-columns/#findComment-1188144 Share on other sites More sharing options...
chewbears Posted March 16, 2011 Author Share Posted March 16, 2011 Think I got it. Found a MySQL book from a training class that answered it. A trigger is just an object within the database. Created by giving it a name an event and then a statement. Displayed by... show triggers Link to comment https://forums.phpfreaks.com/topic/230724-auto-update-columns/#findComment-1188235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.