Will this work in Postgres?
Okay, all you Postgres experts who want to be helpful, here's a question for you: I'm trying to select all revisions of nodes that have revisions other than the current one that are older than a given time and of a selected type(s). The following query does what I need in MySql, will it work in Postgres? SELECT r.nid, r.vid, r.timestamp, DATE( FROM_UNIXTIME(r.timestamp)) AS 'date', n.title, n.type FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid WHERE n.nid IN ( SELECT r.nid FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid AND r.vid <> n.vid WHERE r.timestamp <1248708062 AND n.type IN ('page', 'story') ) ORDER BY r.nid, r.timestamp DESC
From looking at the PG docs, I see that "DATE( FROM_UNIXTIME( r.timestamp ) ) AS 'date'" probably needs to be changed to "CAST(r.timestamp AS date) AS 'date'" and I can do that in my code. The funny thing is that the MySql docs mention doing the same, but it returns a NULL.
Nancy E. Wichmann, PMP Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
On Mon, 24 Aug 2009 13:19:33 -0400 "Nancy Wichmann" <nan_wich@bellsouth.net> wrote:
From looking at the PG docs, I see that "DATE( FROM_UNIXTIME( r.timestamp ) ) AS 'date'" probably needs to be changed to "CAST(r.timestamp AS date) AS 'date'" and I can do that in my code. The funny thing is that the MySql docs mention doing the same, but it returns a NULL.
postgresql has to_timestamp(double precision) from 8.1 but it doesn't seem it is supported by mysql. I think it is better you convert the date on the php side. pg uses " to quote identifiers and alias. Other than that I've no site that really use revisions to really test your sql. Other than that it ran without errors. -- Ivan Sergio Borgonovo http://www.webthatworks.it
participants (2)
-
Ivan Sergio Borgonovo -
Nancy Wichmann