# Database Discussions > MySQL >  Select TOP in MySQL

## Frank

Any idea what is the equivalent of SELECT TOP .... FROM...
in MySQL to retrieve a subset of the records.

Thanks,

Frank

----------


## nicc777

The following should work:



```
SELECT DISTINCT( `cloumnA` ), COUNT( `columnA` ) FROM `tablename` GROUP BY 1 ORDER BY 2 DESC LIMIT 0,10;
```

The nice thing with using _LIMIT_ is that you can use this function to page through your data. If you have a result that returns 23 rows, you could devide it on 3 pages ( giving max 10 rows per page ).

For page 1:



```
SELECT * FROM `tablename` LIMIT 0,10;
```

For page 2:



```
SELECT * FROM `tablename` LIMIT 10,10;
```

For Page 3:



```
SELECT * FROM `tablename` LIMIT 20,-1;
```

For more info, refer to the MySQL documentation 

Cheers

----------


## Frank

Thanks for the tip. I'll check the doc. The -1 of LIMIT 10,-1 must mean from 10 to the end then ... does all MSSQL has this syntax or just a certain version.

Frank

----------


## nicc777

Well, I have used it since earlier 3.x versions, and my current test machine ( 4.0.11a ) shows that it is still working.

Then again - I see you now write about MSSQL. Remember that this is the MySQL forum - _big_ diff  :Smilie:  If you really mean MSSQL, you should post your question in the MS SQL forum.

Of course there will be noe harm if you check out and use MySQL - I am sure the experience will be an enlightenment.

Cheers

----------


## Frank

OH...  I mean MySQL and not MSSQL!!!
Thanks, This LIMIT feature will solve my problem.

Thanks,

Frank

----------

