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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top