Posts Tagged Database Paging

Looking at MySQL

I must admit that I have mostly worked with SQL Server and a little bit with Oracle. I am now getting ready to start a project that will work with MySQL. I was looking at few samples to see how to do different things. One of the coolest things I found in MySQL is the ability to do paging is very simple. Unlike Oracle or SQL 2005 which require complex SQL constructs to build a query that returns a subset of rows at a time, MySQL uses a very simple approach. MySQL uses a keyword called LIMIT and you can specify two values after LIMIT and they are used as the starting point and the ending point of number of rows.

So if you want to create a paged query in MySQL all you have to do is add LIMIT keyword at the end.

select * from `products` LIMIT 10, 5

This query above would return rows that are on positions 11, 12, 13, 14, and 15.

Simple isn’t it? Now match that SQL Server or Oracle!!

I actually never really had to write paged queries by hand as my favorite ORM product Quick Objects always took care of that for me. All I had to do was set two properties even with most complex joins/criteria based queries. Quick Objects guys are saying they will start supporting MySQL in the next release which should be due about now so lets see how that goes.

Another thing I found is the ability to do replication in MySQL. I haven’t fully gone through the docs but thats next.

Leave a Comment