Jump to content

Auto Update Columns


chewbears

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.