mysql - Query to count how many times an ip is used with different accounts -


i single query count how many different customer accounts use same ip log in.

+---------+-------------+------+-----+---------+----------------+ | field   | type        | null | key | default |          | +---------+-------------+------+-----+---------+----------------+ | info_id | int(11)     | no   | pri | null    | auto_increment | | afid    | int(11)     | no   |     | 0       |                | | access  | date        | no   |     | null    |                | | ip      | varchar(15) | no   |     |         |                | +---------+-------------+------+-----+---------+----------------+ 

afid customer id. every time log in row inserted table. have been trying nested selects without luck, , can think of. i'm on thinking :)

thanks in advance!

try this:

select count(distinct afid) afid_count yourtable ip = '....' 

to list of used ips:

select     ip,     count(distinct afid) afid_count yourtable group ip having afid_count > 1 order afid_count desc 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -