Any idea what is the equivalent of SELECT TOP .... FROM...
in MySQL to retrieve a subset of the records.
Thanks,
Frank
Printable View
Any idea what is the equivalent of SELECT TOP .... FROM...
in MySQL to retrieve a subset of the records.
Thanks,
Frank
The following should work:
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 ).Code:SELECT DISTINCT( `cloumnA` ), COUNT( `columnA` ) FROM `tablename` GROUP BY 1 ORDER BY 2 DESC LIMIT 0,10;
For page 1:
For page 2:Code:SELECT * FROM `tablename` LIMIT 0,10;
For Page 3:Code:SELECT * FROM `tablename` LIMIT 10,10;
For more info, refer to the MySQL documentationCode:SELECT * FROM `tablename` LIMIT 20,-1;
Cheers
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
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 :) 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
OH... I mean MySQL and not MSSQL!!!
Thanks, This LIMIT feature will solve my problem.
Thanks,
Frank