enjaku enjaku - 9 months ago 44
MySQL Question

rewrite postgresql query to use with mysql

I have a postgresql query in my Ruby on Rails application, which I have to rewrite to use it with mysql. And I don't understand how to do it, I always have an error and I think it is something concerning timestamps.
Here is the query:

.where("mass_scan_lists.enabled = ?", true)
.order("mass_scan_lists.urgent DESC,
CASE mass_scan_lists.urgent WHEN true THEN extract(epoch from mass_scan_tasks.updated_at) ELSE -extract(epoch from mass_scan_tasks.updated_at) END")


Replace extract(epoch from mass_scan_tasks.updated_at) with unix_timestamp(mass_scan_tasks.updated_at)