List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 15 1999 12:20am
Subject:Re: DISTINCT keyword not doing as I expect...
View as plain text  
At 5:00 PM -0700 7/14/99, DC Mahoney wrote:
>I'm sure I'm overlooking something simple, and I hope one
>of you folks can point out to me my errors.
>
>I'm running MySQL 3.21.31 on Solaris 7. My database "ads"
>contains tables including "homes".  The structure of this
>table is:
>
>slug       char(12),
>class      char(6),
>ad_text    text,
>sort_text  char(32),
>date_added date,
>logo       text,
>photo      text,
>age        smallint
>
>When I do the query:
>   SELECT sort_text, slug, ad_text, date_added, log,
>    photo, class, FROM homes WHERE (class = '705R')
>    AND age <= 1 ORDER BY class, sort_text, date_added DESC
>I get 276 rows returned.  When I modify the query to:
>   SELECT DISTINCT sort_text, slug, ad_text, date_added, log,
>    photo, class, FROM homes WHERE (class = '705R')
>    AND age <= 1 ORDER BY class, sort_text, date_added DESC
>I still get 276 rows returned, though I have several
>(a dozen or so) ads where sort_text is duplicated.
>
>My objective is to get only the most recent occurence
>of each ad.
>
>So how come adding the DISTINCT keyword before the
>"sort_text" column name doesn't give me distinct
>rows?

Because DISTINCT applies to the entire row, not just to sort_text.

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
DISTINCT keyword not doing as I expect...DC Mahoney15 Jul
  • Re: DISTINCT keyword not doing as I expect...Paul DuBois15 Jul
    • Re: DISTINCT keyword not doing as I expect...jkraai15 Jul
  • Optimizing a P133 for MySQLVan15 Jul
    • Re: Optimizing a P133 for MySQLSasha Pachev15 Jul
    • Re: Optimizing a P133 for MySQLJunster15 Jul
      • Re: Optimizing a P133 for MySQLOrlando Andico15 Jul
        • Re: Optimizing a P133 for MySQLJunster15 Jul
          • Re: Optimizing a P133 for MySQLOrlando Andico15 Jul
            • Re: Optimizing a P133 for MySQLEd Carp15 Jul
              • Re: Optimizing a P133 for MySQLOrlando Andico15 Jul
                • Re: Optimizing a P133 for MySQLJon Drukman15 Jul
                  • Re: Optimizing a P133 for MySQLOrlando Andico15 Jul
                • Re: Optimizing a P133 for MySQLChris Trown15 Jul
                  • Re: Optimizing a P133 for MySQLEd Carp15 Jul
                    • Re: Optimizing a P133 for MySQLOrlando Andico16 Jul
                      • Re: Optimizing a P133 for MySQLVan16 Jul
              • Re: Optimizing a P133 for MySQLVan15 Jul
              • Re: Optimizing a P133 for MySQLT├Ánu Samuel16 Jul
                • Re: Optimizing a P133 for MySQLJon Drukman16 Jul
        • Re: Optimizing a P133 for MySQLJon Drukman15 Jul
      • Searching across multiple tablesBrighten Godfrey15 Jul
        • Searching across multiple tablessinisa15 Jul
        • Re: Searching across multiple tablesChristian Mack21 Jul
    • Re: Optimizing a P133 for MySQL {Interim Results}Van16 Jul
      • Re: Optimizing a P133 for MySQL {Interim Results}Ed Carp16 Jul
  • DISTINCT keyword not doing as I expect...Michael Widenius30 Jul
Re: Optimizing a P133 for MySQLDerick H Siddoway16 Jul
Re: Optimizing a P133 for MySQLKen Farwell16 Jul