Jump to content

Need help with MySQL query


Fresh_ales

Recommended Posts

First hi to all ;D

I want to make a query in MySQL and have some problems with it...

I have made it like this

$query = "SELECT * FROM $db_stats
      WHERE user_ip NOT IN
      (
      SELECT user_ip FROM $db_stats
      GROUP BY user_ip
  )
     ";

so.... what it want?

i have user_ip-s in my db and i want to select all records that are more then 1 in database...

that means i there are 2 same ips i want to select one of them....

on the end when i see the query works well i want to delete this records...

help?

Link to comment
Share on other sites

Why don't you do the initial sorting at the INSERT end instead of running a cleanup after the fact?

 

Just make the USER_IP a 'key' and run an INSERT......ON DUPLICATE KEY UPDATE...

 

 

Of course...if you already have the database, then that's not an option for the current clean-up need.  I'm actually not sure how to search the table to only get duplicated rows.

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.