Delphi-PRAXiS
Seite 3 von 4     123 4      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi Problem mit Query (https://www.delphipraxis.net/112483-problem-mit-query.html)

mkinzler 22. Apr 2008 12:32

Re: Problem mit Query
 
Liste der Anhänge anzeigen (Anzahl: 1)
Habe das in FB getestet da macht die Abfrage, was sie soll :gruebel:

MaxMara 22. Apr 2008 12:47

Re: Problem mit Query
 
Sehr seltsam.
Vielleicht liegt es daran, dass MySQL nichts mit a.count(ID) anfangen kann?
(ERROR 1305: FUNCTION a.count does not exist)

mkinzler 22. Apr 2008 12:49

Re: Problem mit Query
 
Sorry der Alias gehört natürlich in die Klammer
SQL-Code:
SELECT a.voting_text, count(a.ID) AS ergebnis FROM ( Select voting_text, MAX( ID) as ID from data group by voting_ip, voting_text) a group by a.voting_text;

MaxMara 22. Apr 2008 13:30

Re: Problem mit Query
 
Also bei mir sieht es jetzt so aus:
SQL-Code:
mysql> SELECT a.voting_text, count(a.ID) AS ergebnis FROM ( Select voting_text, MAX(voting_id) as ID from data group by voting_ip, voting_text) a group by a.voting_text;
geändert von mir wurde lediglich das
SQL-Code:
MAX(voting_id) as ID ...
weil wenn ich nur MAX(ID) hier nehme bringt er den Fehler "Unknown column 'ID' in 'field list'"

Auf jeden Fall bringt "mein" SQL nicht den gewünschten Effekt.

Im Übrigen möcht ich mich schon mal für den Einsatz bedanken! Find ich echt toll! Danke!

mkinzler 22. Apr 2008 13:39

Re: Problem mit Query
 
Führe mal nur die innere Abfrage aus und lass dir das Ergebnis anzeigen

MaxMara 22. Apr 2008 13:43

Re: Problem mit Query
 
Das hier:

Code:
+-------------+------+
| voting_text | ID  |
+-------------+------+
| Ja         |    2 |
| Ja         |    1 |
| Nein       |    3 |
+-------------+------+

mkinzler 22. Apr 2008 13:45

Re: Problem mit Query
 
Wie sieht die komplette Tabelle dazu aus?

MaxMara 22. Apr 2008 13:50

Re: Problem mit Query
 
so:
Code:
+-----------+---------------------+-------------+-----------+
| voting_ip | voting_date        | voting_text | voting_id |
+-----------+---------------------+-------------+-----------+
| 10.0.60.1 | 2008-04-21 11:43:00 | Ja         |         1 |
| 10.0.60.2 | 2008-04-21 11:40:00 | Ja         |         2 |
| 10.0.60.1 | 2008-04-21 15:13:00 | Nein       |         3 |
+-----------+---------------------+-------------+-----------+

mkinzler 22. Apr 2008 13:55

Re: Problem mit Query
 
Ok. Ich Gruppiere ja nach Text und ID

SQL-Code:
SELECT a.voting_text, count(a.ID) AS ergebnis FROM
(select c.voting_text, MAX(b.voting_id) as ID from data b join data c on c.id = b.ID group by voting_ip) a
group by a.voting_text;

MaxMara 22. Apr 2008 13:58

Re: Problem mit Query
 
ERROR 1054 (42S22): Unknown column 'c.id' in 'on clause'


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:18 Uhr.
Seite 3 von 4     123 4      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz