SELECT DISTINCT greift nicht

  • SELECT DISTINCT greift nicht

    Hallo,

    Um doppelte Ausgaben im Wordgraph (Wortwolke) zu vermeiden habe ich es mit SELECT DISTINCT versucht.
    Es wird zwar kein Fehler ausgegeben aber dafür sind Einträge weiterhin doppelt.

    Was ist daran Falsch?

    Quellcode

    1. $cloud = '';
    2. SELECT DISTINCT(s.s_word_value), m.*, s.* FROM
    3. ' . SEARCH_INDEX . ' AS s,
    4. ' . SEARCH_MATCH . ' AS m
    5. WHERE s.s_word_id = m.m_word_id
  • Auch wenn die Art wie du DISTINCT benutzt es vermuten lässt. In MySQL gilt der DISTINCT immer auf die gesamte Zeile.

    The ALL and DISTINCT options specify whether duplicate rows should be returned. ALL (the default) specifies that all matching rows should be returned, including duplicates. DISTINCT specifies removal of duplicate rows from the result set. It is an error to specify both options. DISTINCTROW is a synonym for DISTINCT.
    dev.mysql.com/doc/refman/5.1/en/select.html

    Wenn du eine einzige Spalte eindeutig haben willst, dann arbeite mit GROUP BY. Ist in einer Tagcloud sowieso besser, denn auf die Art bekommst du auch einen Count.