MySQL Forums
Forum List  »  German

Re: DISTRINCT weiter eingrenzen
Posted by: Thomas Wiedmann
Date: April 08, 2012 11:25AM

Hallo Torsten,

Du lieferst zu wenig Informationen, um Dir eine valide Antwort liefern zu können:

Dein SQL-Beispiel funktioniert nicht. Vermutlich meinst Du DISTINCT.

Damit die Datenbank nur einen Datensatz liefert, musst Du ein weiteres Kriterium in der WHERE Klausel angeben, der die Ergebnismenge wie gewünscht einschränkt oder eventuell den LEFT JOIN in JOIN umbauen (geraten).

Was kommt raus, wenn die aus dem LEFT JOIN ein JOIN machst?
SELECT artikel.*, objekte.objekt_text 
  FROM `artikel` 
  JOIN `objekte` 
    ON objekte.objekt_artikel_id = artikel.id 
 WHERE objekte.objekt_text LIKE '%Hund%'

Wenn dies nicht ausreicht, dann bitte ein vollständiges Beispiel zusammenstellen:
a) CREATE TABLE von allen beteiligten Tabellen ( z. B. mysql>SHOW CREATE TABLE tbl1; )
b) passende Testdaten (INSERT ...) zu allen beteiligten Tabellen
c) Das Ergebnis dass jetzt rauskommt
d) das erwünschte Ergebnis

Grüße
Thomas

Options: ReplyQuote


Subject
Views
Written By
Posted
1760
April 08, 2012 11:07AM
Re: DISTRINCT weiter eingrenzen
1034
April 08, 2012 11:25AM
971
April 08, 2012 11:52AM
1025
April 08, 2012 11:59AM
1429
April 08, 2012 12:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.