Query help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Al

    #1

    Query help

    Hello,

    I have a table with columns 'user_ip' and 'user_name'. I need to find
    out users who are logged under several logins with the same IP.

    I really don't know how to do this !

    Any help will be very appreciated
    Thanks in advance
  • Ilya
    New Member
    • Nov 2005
    • 2

    #2
    SELECT 'user_name' FROM `database` WHERE 'user_ip'='000. 00.00.0'

    Also you can use in expression WHERE full or part of a IP using the string function of the mysql.

    Comment

    • Markus Popp

      #3
      Re: Query help

      Try

      select user_name, user_ip, count(*) as cnt
      from table
      group by user_name, user_ip
      order by user_name, cnt desc

      This gives you a list of all user names and ip addresses with the number of
      logins.

      You can limit the output using a having clause, like

      select user_name, user_ip, count(*) as cnt
      from table
      group by user_name, user_ip
      having cnt > 1
      order by user_name, cnt desc

      which e.g. shows you only the user names and ip addresses that have logged
      in more than once.

      Markus


      Comment

      Working...