1 Replies - 2290 Views - Last Post: 09 January 2015 - 10:20 PM

#1 SpaceMan   User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

DeDup records

Posted 13 February 2008 - 09:36 AM

Description: Change settings, upload and run. if you cant create the table with the page due to permissions, make it manually in some admin program.With MySQL you can not update in the same query of returned records. simple work around. in PHP, but can add the sql to your lang.
db errors " [email protected]_error()."
rn");
}  

$SQL = '
INSERT  INTO `'.DB_TEMP_TABLE.'`
(SELECT MIN( `'.DB_DEDUP_ID_NAME.'` ) `'.DB_DEDUP_TABLE.'`.`'.DB_DEDUP_ID_NAME.'`
FROM `'.DB_DEDUP_TABLE.'`
GROUP  BY `'.DB_DEDUP_TABLE.'`.`'.DB_DEDUP_FIELD_NAME.'`
HAVING count(  *  )  >1)
';        
  if([email protected]_query($SQL))
    exit($SQL."
rndb errors " [email protected]_error()."
rn");

$SQL = '
SELECT count(*) FROM `'.DB_DEDUP_TABLE.'`
';        
  if(@mysql_fetch_array(@mysql_query($SQL)))
    exit($SQL."
rndb errors " [email protected]_error()."
rn");


$SQL = '
DELETE FROM `'.DB_DEDUP_TABLE.'` WHERE `'.DB_DEDUP_ID_NAME.'` IN ( SELECT id FROM `'.DB_TEMP_TABLE.'`)
';        
  if([email protected]_query($SQL))
    exit($SQL."
rndb errors " [email protected]_error()."
rn");

echo 'mysql_affected_rows ' . @mysql_affected_rows();

$SQL = '
TRUNCATE TABLE  `'.DB_TEMP_TABLE.'`
';        
  if([email protected]_query($SQL))
    exit($SQL."
rndb errors " [email protected]_error()."
rn");


?>


Is This A Good Question/Topic? 0
  • +

Replies To: DeDup records

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12634
  • View blog
  • Posts: 45,800
  • Joined: 27-December 08

Re: DeDup records

Posted 09 January 2015 - 10:20 PM

Note: The mysql_*() family of functions is deprecated. Please refer to MySQLi or PDO, using prepared statements in particular. I will leave this snippet as the concept is still valid and the mysql_*() functions were valid back in 2008, when this snippet was submitted.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1