ThWboard Support-Forum (Archiv)

Ort: / Boardübersicht / PHP / MySQL Probleme / Problem mit Match Against


Seite 1 von 1

PhoenixDH schrieb am 21.04.2005 um 14:13 Uhr

Ich habe ein Problem mit einer SQL Abfrage, der Quellcode sieht folgendermaßen aus:

Hiermit werden die Auswahlen erzeugt:

$orderbyoptions = array(
    'ORDER BY images' => 'Bilder',
    'ORDER BY c.category_id' => 'Album ID',
    'ORDER BY c.entrytime' => 'Datum',
    'ORDER BY c.category_name' => 'Name',
    'WHERE MATCH (c.category_name) AGAINST (Opel)' => 'Opel'
);

und das ist die Abfrage:

$result = thwb_query("SELECT c.category_id,c.category_name,COUNT(photo_id),c.entrytime, COUNT(p.photo_id) AS images
FROM ".$pref."gallery_category as c
LEFT JOIN ".$pref."gallery_photos as p ON p.photo_category = c.category_id
GROUP BY c.category_id $orderby $ordertype LIMIT $from, $max_cat" );

Das klappt nicht wirklich, es kommt folgende Fehlermeldung im Browser:

MySQL: 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 'WHERE MATCH (c.category_name) AGAINST (Opel) ORDER BY images desc LIMIT 0, 15' at line 4
Query: SELECT c.category_id,c.category_name,COUNT(photo_id),c.entrytime, COUNT(p.photo_id) AS images
                                                FROM tb_gallery_category as c
                                                LEFT JOIN tb_gallery_photos as p ON p.photo_category = c.category_id
                                                GROUP BY c.category_id WHERE MATCH (c.category_name) AGAINST (Opel) LIMIT 0, 15

WOran kann das liegen ?

theDon schrieb am 22.04.2005 um 15:28 Uhr

Select Syntax

SELECT -- hier gekuerzt --
[FROM table_references
      [WHERE where_definition]
      [GROUP BY {col_name | expr | position}
        [ASC | DESC], ... [WITH ROLLUP]]

http://dev.mysql.com/doc/mysql/en/select.html

PhoenixDH schrieb am 22.04.2005 um 17:02 Uhr

Ok, danke !
Hab die Syntax jetzt so hingebogen das das passt, denn das ORDER by, das in dem Arry noch drin muss ja hinter das group ...

Aber ein Problem hab ich noch:

Unknown column 'Opel' in 'where clause'

$orderbyoptions = array(
    'GROUP BY c.category_id ORDER BY images' => 'Bilder',
    'GROUP BY c.category_id ORDER BY c.category_id' => 'Album ID',
    'GROUP BY c.category_id ORDER BY c.entrytime' => 'Datum',
    'GROUP BY c.category_id ORDER BY c.category_name' => 'Name',
    'WHERE MATCH (c.category_name) AGAINST (Opel) GROUP BY c.category_id' => 'Opel'
);

Ich bekomme das einfach net weg die Meldung !

bdominik schrieb am 22.04.2005 um 18:41 Uhr

sagmal, liest du eigentlich nie doku? um strings müßen in mysql zumindest ' außen herum.

PhoenixDH schrieb am 22.04.2005 um 19:38 Uhr

Jetzt geht es, war zusätzlich noch was anderes !

Aber ich hab da ein Problem mit 2 Begriffen, bei denen er m ir nichts anzeigt obwohl er das müsste, das eine BMW und das andere VW, liegt das daran das die Buchstaben alle zu groß sind oder weil es zu wenige sind ?

theDon schrieb am 23.04.2005 um 21:15 Uhr

sagmal, liest du eigentlich nie doku?

...

Some words are ignored in full-text searches:
Any word that is too short is ignored. The default minimum length of words that are found by full-text searches is four characters.

http://dev.mysql.com/doc/mysql/en/fulltext-search.html

Seite 1 von 1