MySql's equivalence to MsSql's 'TOP' command/function/clause

G

Guest

Hi,

I'm trying to do some Custom Paging technique with the datagrid object and
with the select command in Sql, thus forcing the server to only select those
rows from the database that should be rendered in the datagrid object.

This works fine with the code I have in MsSql2k but now I'm trying to do the
same with MySql v4.1 database and it doesn't support the 'TOP'
command/function/clause and I'm looking for some equivalence in MySql syntax,
but can't find it.

What I have?
A DateTime column with some swedish 100% unique formatted dateTime rows,
there's exactly one second between every row, if necessary to get in exactly
unique in a bigger table I will have it to the thousend of a second

2003-01-01 00:00:01
2003-01-01 00:00:02
..........
2003-01-01 00:31:45
2003-01-01 00:31:46

and so on . . . .

An OdbcString with a DateTime table column named DatumTid, a DateTime
variable named varDatumTid

Const PageSize = 20
OdbcString = "Select Top " & PageSize.toString() & " * from testMySql " _
& "Where DatumTid > '" & ViewState( "varDatumTid" ).toString() & "'" _
& " Order By DATUMTID"

What I need?

An equivalence to the MsSql 'Top' command/function/clause in MYSql v4.1

Perhaps with some extra stuff around it to get it working.

TIA

Regards,
Kenneth P
 
J

John Timney \(ASP.NET MVP\)

You want the The LIMIT clause which is used to limit the records returned by
the SELECT statement. You specify the start row (start from zero), and the
number of records returned.

SELECT * FROM search LIMIT 0, 10;

Have a look a the docs for mySQL

--
Regards


John Timney
ASP.NET MVP
Microsoft Regional Director
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top