(SQL) help needed

Soldato
Joined
1 Feb 2006
Posts
8,188
hi guys,

i should know how to do this but my brain just isnt on top form today..

I have a database table containing articles which are identified by an "articleID"

On the home page of the site I want to constantly display the top 5 articles.

How can I do this using sql?

This is what I have so far

Code:
$result = mysql_query("SELECT * FROM announcements_test ORDER BY articleID DESC");

This gets the latest articles and puts them in descending order based upon articleID which is set to auto increment in my database.

I think i could maybe limit it to five articles using the count function but just cant get it!

Any help would be cool

Thanks
J
 
Code:
$result = mysql_query("SELECT [color=red]TOP 5[/color] * FROM announcements_test ORDER BY articleID DESC");
would do it if it was SQL-Server
 
thanks guys, sorted!

another other sql problem.. what is collation all about and why are some of my variables classes as "unsigned". Anyone want to explain this to a newbie?

Im using phpmyadmin and its a curse to work with unless writing in the sql commands directly
 
Back
Top Bottom