Posted by Toby A Inkster on 04/16/07 10:20
roondog wrote:
> I would now like to only show a certain number of the news articles.
> Say the latest five.
Certain databases allow you to use a "LIMIT" clause to limit the number of
results returned by a SELECT query. Because this is not part of the
official SQL standard, the exact syntax varies between databases. Here are
some examples:
MySQL:
SELECT * FROM articles ORDER BY created_date DESC LIMIT 5;
PostgreSQL:
SELECT * FROM articles ORDER BY created_date DESC LIMIT 5;
Microsoft SQL Server:
SELECT TOP 5 * FROM articles ORDER BY created_date DESC;
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
Navigation:
[Reply to this message]
|