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
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.