Wednesday 7 March 2012

Updating a database table based on dates from a related table


Ever been caught out when you need to update a database table based on the date of a field in another (related) tables?

For example update sales table 5 days after a product shipped (maybe for a survey / follow up.

Example SQL would be :





UPDATE sales as s
LEFT JOIN shipped as e
ON s.shipping_id=e.sales_id
SET s.shipped=true
WHERE NOW() > DATE_ADD(e.shipped_at, INTERVAL 120 HOUR)
AND s.shipped=false

Easy huh!

Sunday 4 March 2012

Hengist Inaugural Engineering Committee meeting

A very productive inaugural Engineering Committee meeting updating on progress and setting out future works including the Main Frames, Build plan (with yours truly aiding with the MS Project side).
It was also a chance to put some names to faces. The group is a friendly group focused on the tasks ahead. I will bring more updates on the progress of the project. For now though if you're interested in steam locomotives, heritage, engineering or are just feeling nosey please visit our website at www.72010-hengist.org.uk. Not only does the site contain a wealth of information on the locomotive, the history of the BR Standard Class 6 'Clans' but also progress news and information on how you can help bring this locomotive to the mainline.


Thursday 1 March 2012

Another quick tip for those RoR developers using Sphinx / Thinking sphinx as a search backend.

Sanitising your search string with Riddle.escape

e.g. Riddle.escape( :params[query] )