473,624 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.toStri ng() & " * from testMySql " _
& "Where DatumTid > '" & ViewState( "varDatumTi d" ).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
1 3520
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******@discu ssions.microsof t.com> wrote in message
news:41******** *************** ***********@mic rosoft.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.toStri ng() & " * from testMySql " _
& "Where DatumTid > '" & ViewState( "varDatumTi d" ).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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3516
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary form for a number of platforms from our download pages at http://www.mysql.com/downloads/ and mirror sites.
1
2402
by: Max Favilli | last post by:
Hello everybody, I have just installed mysql to evaluate it, I have an application based on mssql which extensively use the "for xml" clause to retrieve data from the db as xml well formed document (actually "for xml explicit"). How can I do the same thing with mysql? I understood there's no native support for retrieving data as xml document, but there is any add-on, plugin, library... Anything which is very very fast (I intend to use it...
2
9290
by: jblankenburg | last post by:
Please help! I am hunting high and low for an equivalent function for MSSQL's DATENAME function. Here's the spec on the function from MSSQL's Books Online: DATENAME Returns a character string representing the specified datepart of the specified date.
6
38493
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
5
1815
by: M. Savas Zorlu | last post by:
Hi, I just decided to leave Mssql and start using Mysql. I am having some problems with my queries; is there anyone here who has a knowledge of query syntax in Mysql? If so, I need some help with couple of queries.
8
2707
by: pechar | last post by:
Hi all, I created an application to copy certain tables from a database on MSSQL server to another database on MYSQL server which is on another server (very very very far away). The process works well but it terribly slow. And were only talking text... no images are in the database yet. I used ADO.Net and .NET ODBC Connection to MYSQL. What I do is select the data from MSSQL tables to a dataset using a source DataAdapter and and then...
15
1281
by: Cirene | last post by:
I'm trying to convince my client that MySQL server is not the way to go for his project. Here are some reasons why... - If you use the MySQL Connector you are bound to GPL (unless you want to pay $$$) - Doesn't work as good "out of the box" with Visual Studio 2008 Any other reasons why SQL Server is better than MySQL? I was thinking about using SQL Express, but my client says it's too limited. Any thoughts? Thanks!
0
4428
by: silversubey | last post by:
I am trying to convert mssql triggers to mysql. I am very new to Mysql and would like some help with my code. My queries work but there has to be a more efficient way to write them. I would greatly appreciate any help. the following is a trigger that works until I add the last update statement. thanks for the help. Mysql 5 delimiter // Create TRIGGER User_Rating_Avg After Insert on bksite.Ratings FOR EACH ROW BEGIN UPDATE...
0
1561
by: johnyjj2 | last post by:
Hello! I've got web application written in MSSQL and I need to run it on server. But on the server I've go MySQL (not MSSQL), PHP, KFWS. Do I have to install MSSQL and have both MySQL and MSSQL? Won't it make any problems? Can I use 4CRM SQL 5.1.4 or EMS MS SQL Manager Lite 1.8 to run my MSSQL web application? How to run it? (In the web application I've got two directories. One which I copied to htdocs on KFWS, the other with scripts. At the...
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8672
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8614
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.