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/