Re: sorting join

From: Bob Crispen (bob.crispen_at_boeing.com)
Date: 18 March 2003


Found this news:32d7a63c.0303161625.5749ba75_at_posting.google.com in comp.lang.php:

-= BEGIN forwarded message =-

Subject: Re: sorting join
From: nc_at_iname.com (Nikolai Chuvakhin)
Newsgroups: alt.php,comp.lang.php
Organization: http://groups.google.com/

nc_at_iname.com (Nikolai Chuvakhin) wrote in message

   news:<32d7a63c.0303161001.4fecbcbe_at_posting.google.com>...
>
> SELECT
> slides.file,
> slides.moment,
> users.id,
> users.username
> FROM
> slides LEFT JOIN users ON slides.userid=users.id
> WHERE slides.id=MAX(slides.id)
> GROUP BY users.id;

Oops... Where was my head? :) HAVING, not WHERE:  

SELECT
  slides.file,
  slides.moment,
  users.id,
  users.username
  FROM
    slides LEFT JOIN users ON slides.userid=users.id   GROUP BY users.id
  HAVING slides.id=MAX(slides.id);

Cheers,
NC

-= END forwarded message =-

-- 
Bob Crispen
bob.crispen_at_boeing.com
That which does not kill us has made its last mistake.


This archive was generated by hypermail pre-2.1.8 : 26 April 2003 EDT