enjaku enjaku - 1 year ago 78
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")

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download