List Info

Thread: Re: Avoiding sub-queries




Re: Avoiding sub-queries
country flaguser name
Australia
2007-04-23 08:38:20
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  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
...

Re: Avoiding sub-queries
country flaguser name
United States
2007-04-23 08:56:31
On Apr 23, 2007, at 9:38 AM, sime wrote:

> So if $count = 5:
>
> 1
> 2
> 4
> 8
> 9  <-- you want this nid?
> ------- limit
> 11
> 12
> 14
> ...

Exactly.


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )