> But in your case I don't see the need for the subquery. (Sorry, managed to send that before it was done.) Is this what you're trying to do? db_result(db_query(db_rewrite_sql('SELECT max(n.nid) FROM {node} n ORDER BY n.nid LIMIT %d'), $count));