Try

SELECT lastip,username FROM users HAVING count(*) > 1 GROUP BY lastip;

(or possibly 

SELECT lastip,username FROM users GROUP BY lastip HAVING count(*) > 1;

)

david

On Wednesday 24 October 2001  2:21 pm, David Wolf wrote:
> I'm trying to come up with a query to do the following... I'm not having
> lots of luck :(
>
> The table is a user database. The columns I'm interested in are: username,
> lastip. I'm interested in pulling information out that would show usernames
> for each IP that appears more than once in the database.. i.e.
>
> username        ip
> persona        1.1.1.1
> personb        1.2.3.4
> personc        1.1.1.1
>
> I'd be interested in seeing persona and personc (both have 1.1.1.1 ip's)
>
> I've tried..
>
> SELECT lastip,count(*) FROM users GROUP BY lastip;
>
> but that only gives me an unordered list of the # of times an IP is used..
>
> SELECT distinct(count(*)) FROM users GROUP BY lastip;
>
> but that doesn't join the info -- nor give me the ip's -- just frequency
> (when I add 'lastip' to the select I get an error)
>
> I'm thinking that I'm going about this the wrong way.. But, I can't quite
> get a clue.
>
> Can anyone help me out here?
>
> Thanks!
>
> David Wolf
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-- 
Dave

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to