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
https://forums.phpfreaks.com/topic/43791-need-help-with-mysql-query/
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.

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.