![]() |
SELFHTML Forumsarchiv |
|
|
Die folgende Nachricht zum Thema stammt von: Kalle_B, 29. 02. 2008, 16:15
Hallöle,
ich möchte trotz LIMIT wissen, wieviel Sätze eine Abfrage ohne LIMIT ergeben hätte.
Aus der Doku http://dev.mysql.com/doc/refman/5.0/en/information-functions.html
habe ich entnommen, dass SQL_CALC_FOUND_ROWS einzufügen ist.
Doch nach Einfügen dieses Wortes wird ein Fehler gemeldet:
1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ort1.*
,ort2.id ort2_id
,ort2.name ort2_name
,ort2.region_id ' at line 6
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ORTE LESEN ZUR ANZEIGE
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT
SQL_CALC_FOUND_ROWS
,ort1.*
,ort2.id ort2_id
,ort2.name ort2_name
,ort2.region_id ort2_region_id
,ort3.id ort3_id
,ort3.name ort3_name
FROM bia_orte AS ort1
LEFT JOIN ( bia_orte AS ort2,
bia_orte AS ort3 )
ON ( ort2.id = ort1.region_id AND
ort3.id = ort2.region_id )
WHERE 1=1
AND (( ort2.name LIKE '%bergstra%' ) OR ( ort2.name_zusatz LIKE '%bergstra%' ))
ORDER BY ort1.name, ort1.name_zusatz
LIMIT 0,25
In der Doku steht SQL_CALC_FOUND_ROWS allein nach SELECT. Aber dann erhalte ich ja meine Felder nicht.
Was habe ich falsch gemacht?
MfG Kalle
Die folgende Nachricht zum Thema stammt von: Marc Reichelt, 29. 02. 2008, 16:21
Hallo Kalle_B,
»» Was habe ich falsch gemacht?
Du hast ein Komma vor dem SQL_CALC_FOUND_ROWS. Daran wird es vermutlich liegen.
Grüße
Marc Reichelt || http://www.marcreichelt.de/
--
panic("Oh boy, that early out of memory?");
linux-2.2.16/arch/mips/mm/init.c
Selfcode: ie:{ fl:| br:> va:} ls:< fo:} rl:( n4:( ss:) de:> js:| ch:? sh:| mo:) zu:)
Die folgende Nachricht zum Thema stammt von: Kalle_B, 29. 02. 2008, 16:33
Hallo Marc,
»» Du hast ein Komma vor dem SQL_CALC_FOUND_ROWS. Daran wird es vermutlich liegen.
Stehe ich auf dem Schlauch? Wo ist da ein Komma?
SELECT
SQL_CALC_FOUND_ROWS
,ort1.*
...
Die folgende Nachricht zum Thema stammt von: Kalle_B, 29. 02. 2008, 16:37
Hallo Marc,
habe mit dem Kommas rumprobiert, so geht es:
SELECT
SQL_CALC_FOUND_ROWS
ort1.*
,ort2.id ort2_id
...
hatte ich noch nie, dass zwischen zwei Elementen _kein_ Komma steht.
Danke.
MfG Kalle
Die folgende Nachricht zum Thema stammt von: dedlfix, 29. 02. 2008, 18:06
echo $begrüßung;
»» SELECT
»» SQL_CALC_FOUND_ROWS
»» ort1.*
»» ,ort2.id ort2_id
»» ...
»»
»» hatte ich noch nie, dass zwischen zwei Elementen _kein_ Komma steht.
Das ist ja auch kein Element im Sinne von Feld sondern ein Schlüsselwort wie beispielsweise DISTINCT. Und davon zählt das MySQL-Handbuch noch eine Menge mehr auf: SELECT Syntax.
echo "$verabschiedung $name";
Die folgende Nachricht zum Thema stammt von: Marc Reichelt, 29. 02. 2008, 16:52
Hallo Kalle_B,
»» »» Du hast ein Komma vor dem SQL_CALC_FOUND_ROWS. Daran wird es vermutlich liegen.
»»
»» Stehe ich auf dem Schlauch? Wo ist da ein Komma?
»»
»» SELECT
»» SQL_CALC_FOUND_ROWS
»» ,ort1.*
Tschuldige, ich meinte natürlich _nach_ SQL_CALC_FOUND_ROWS. ;-)
Grüße
Marc Reichelt || http://www.marcreichelt.de/
--
panic("Oh boy, that early out of memory?");
linux-2.2.16/arch/mips/mm/init.c
Selfcode: ie:{ fl:| br:> va:} ls:< fo:} rl:( n4:( ss:) de:> js:| ch:? sh:| mo:) zu:)
© 1998-2006
Impressum, Software: Classic Forum