[thesite] rudy, this may intersest you..

Joshua Olson joshua at alphashop.com
Fri Oct 5 12:53:39 CDT 2001


: > select who,  lastlogin, createdate
: >      from users
: >     where exists
: >   (select 1 from users u2
: >       where u2.email = users.email
: >         and u2.userid != user.userid)
: >
: > Or something like that.
:
: indeed, that's pretty close -- in fact it does give you the
: right answer, except that it includes every user twice!

I don't think it does because of the u2.userid != user.userid conditional.
That makes sure it excludes counting itself.

Of course, putting the group by subquery in the IN clause is a much better
answer.  Can you say, deja vu?  I think we covered something like this on
thelist about a month ago.

And then you say,

: (he said, confidently, not having bothered to test it)

DOAH!


-joshua








More information about the thesite mailing list