You are here: Re: I have a tricky MySQL Query « All PHP « IT news, forums, messages
Re: I have a tricky MySQL Query

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация