Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Top query in MySQL

leave a comment »

If we are using SQL Server, generally we use TOP 10 to return top 10 rows of the table.

But in mysql it doesn’t work. We need to use following query to return top x result.

SELECT * FROM test.product p limit 10;

it returns top 10 records from product table. You can also define offset from where you want top 10 record. It is as follows:

SELECT * FROM test.product p limit 10 offset 10;

it returns first 10 records from 10th record.

Advertisements

Written by Manish

March 12, 2008 at 7:48 am

Posted in MySQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: