Jump to content

[SOLVED] SIMPLE MYSQL QUERY


Goose87

Recommended Posts

Hey everyone,

 

I have a quick problem with my script.

 

Basically I'm creating an admin page so that some people that moderate my site can check things like multiple registrations from the same IP.

 

My query which selects the IP and counts the number of times that one is registered is:

 

SELECT ip, COUNT(id) FROM a_users GROUP BY ip

 

This works fine and displays:

 

ip       COUNT( id )

*IP ONE*          14

*IP TWO* 4

*IP THREE* 1

*IP FOUR* 1

 

Basically, I want to change the query so that is only brings back results that have a COUNT(id) value that is higher than 2.

 

Thanks a lot,

 

Goose.

 

 

Link to comment
https://forums.phpfreaks.com/topic/79987-solved-simple-mysql-query/
Share on other sites

SELECT ip, COUNT(id) FROM a_users GROUP BY ip WHERE COUNT(id) > 2

 

Be warned though that users in public locations (libraries, computer labs, college campuses, etc.) will all come from the same IP until that location receives a new IP address from it's ISP.

I'm still getting the error i got when i tried to do that before.

 

The error is:

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE COUNT( id ) > 2

LIMIT 0, 30' at line 1

 

when i typed:

 

SELECT ip, COUNT( id ) 
FROM users
GROUP BY ip
WHERE COUNT( id ) >2
LIMIT 0 , 30

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.