By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,295 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,295 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"Kenneth P" <Ke******@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
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

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.