| 
 Posted by Wog George on 04/11/06 14:11 
"Gerry Vandermaesen" <gerry.vandermaesen@gmail.com> wrote in message  
news:1144752252.525504.307470@z34g2000cwc.googlegroups.com... 
> 
> endlesstide@gmail.com wrote: 
>> how would I 
>> query the database and request the first 50 records, sorted by 
>> ascending value? 
> 
> I'd say a plain simple "SELECT * FROM table ORDER BY number LIMIT 50"; 
> 
> Have the "number field" indexed for optimization. MySQL also optimizes 
> the LIMIT clausule. 
> 
>>  - and also how would I query the database for a 
>> certain set of records by Unique ID such as 250 thru 300 --- and see 
>> those records in ascending order -relative- to the total record set? 
> 
> Not sure of what you are asking here. This is how you select records 
> with id from 250 up to 300: 
> 
> "SELECT * FROM table WHERE id >= 250 AND id <= 300"; 
> 
 
The more conventional way would be "SELECT * FROM table WHERE id BETWEEN 250  
AND 300"; 
 
BETWEEN isn't strictly "between" because it includes the start and end  
values as well. 
 
> Add " ORDER BY id" to order them on id or leave this way to get them in 
> the order they are stored in the database. 
>
 
  
Navigation:
[Reply to this message] 
 |