Web Hosting Talk







View Full Version : does mysql 4.0 support this...


cis4life
05-28-2004, 12:17 AM
Im just getting started with MySql (was using MS SQL) but this is a budget project we are working on so MySql will be used.

My question is...
Does MySql 4.0 support statements like Select Top 5.... ?
I heard 3.0 didn't so thats why Im asking...

Thanks,
Cedric

luki
05-28-2004, 01:19 AM
Not sure what you mean by "top 5" by you certainly can sort by any column with ORDER BY and/or get a range of records with LIMIT.

cis4life
05-28-2004, 01:31 AM
This is what i mean...
"Select Top 5 ID, news_date, title from news_db order by news_date desc"

This is the sql statement that will return the top 5 rows from the return set.

Do MySql 4.0 support this statment?

Cedric

Loon
05-28-2004, 03:51 AM
Yes, you can use the LIMIT clause, see here for info: http://dev.mysql.com/doc/mysql/en/SELECT.html

basically, you would have something like:

SELECT id,news_date,title FROM news ORDER BY news_date DESC LIMIT 5

cis4life
05-28-2004, 04:25 PM
Thanks,

That will work,

Cedric