Autor Beitrag
eternity
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Fr 07.05.04 22:01 
Guten Tag !

Meine Frage bezieht sich auf das limitieren von Datensätze unter mySQL.

Wie kann ich unter Delphi-Application via TQuery die Datensätze begrenzen ?


Dieses Beispiel funktioniert leider nicht !

ausblenden Delphi-Quelltext
1:
Query.SQL.Text:='SELECT * FROM myTable WHERE spalte=egal LIMIT 0,10';					



Der MyODBC-Treiber und mySQL-Server sind installiert und laufen einwandfrei.
Ich habe auch bereits MyDAC in betracht gezogen.

Ich würde aber ganz gerne Wissen wollen ob es auch ohne geht.


Ich würde mich freuen wenn es eine Lösung gibt.


MfG

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 09.05.04 10:13 
unter MS-SQL gehts mit select top 100 (ersten hundert sätze) bzw. select top 50 percent (die ersten 50 Prozent) ob das MySQL kann, keine Ahnung. Probiers mal.
grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
lubo37
Hält's aus hier
Beiträge: 14

Win 95, Win 98, Win 2K WS/SV, XP Home+Prof
D1- D6 EE, D7/ AR, D8 AR, K3
BeitragVerfasst: Mo 10.05.04 10:47 
Titel: LIMIT unter MySQL
Versuchs mal nach Doku ...LIMIT funktioniert.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must be integer constants. With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1): 
mysql> SELECT * FROM table LIMIT 5,10;  # Retrieve rows 6-15

For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax. To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last: 
mysql> SELECT * FROM table LIMIT 95,18446744073709551615;

With one argument, the value specifies the number of rows to return from the beginning of the result set: 
mysql> SELECT * FROM table LIMIT 5;     # Retrieve first 5 rows


Bei sortierten Abfragen muss man ggf. aufpassen, ob das sortierte Ergebnis oder die unsortierte Menge
zurückgegeben wird. Dies gilt vor allem bei SubSelects.


PS : Bei Oracle funktionierts mit ".... where rownum between 100 and 200" oder "... where rownum < 100";

Gruß :wink:
Lutz Bodes
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 10.05.04 10:55 
@eternity
Mit was für Komponenten greifst Du auf die MySQL-DB zu?

Wenn Du ADO benutzt, würde ich statt einer TQuery eine TADOQuery nutzen.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mo 10.05.04 12:20 
Wenn Du myODBC nutzt kanns sein, dass es gar nicht geht. Kommt auf die myODBC-Version an.

Eventuell Umstieg auf Zeos, da gehts definitiv.

_________________
Ha! Es compiliert! Wir können ausliefern!