[development] Avoiding sub-queries

sime info at urbits.com
Mon Apr 23 13:38:20 UTC 2007


Darren Oh wrote:

> On Apr 23, 2007, at 12:18 AM, Nedjo Rogers wrote:
>
>>> But in your case I don't see the need for the subquery.
>>
>>
>> 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));
>
>
> That's exactly what I'm trying to do. But I always get the highest  
> node ID in the table, rather than the highest in the range. That's  
> why I used the sub-query to force the max ID to be selected from  
> within the range.
>
>
So if $count = 5:

1
2
4
8
9  <-- you want this nid?
------- limit
11
12
14
...


More information about the development mailing list