How to recover lost data in a query
I am using this query to duplicate title, description but the titles that are identical are deleted.
What is missing or wrongly coded?

	
$query = "CREATE TEMPORARY TABLE to_delete (title VARCHAR (200), min_id INT(4) NOT NULL);";

  $result = mysql_query ($query) or sql_error($query);



  $query = "INSERT INTO to_delete SELECT title, MIN(id) FROM cas_phocagallery GROUP BY title HAVING COUNT(*) > 1;";

  $result = mysql_query ($query) or sql_error($query);



  $query = "DELETE from cas_phocagallery WHERE EXISTS(SELECT min_id from to_delete WHERE to_delete.title = cas_phocagallery.title and to_delete.min_id != cas_phocagallery.id);";

  $result = mysql_query ($query) or sql_error($query);



  $query = "REPLACE INTO cas_phocagallery(title, catid, alias, filename, description, date,published,approved) SELECT title, '12' AS catid, alias, filename, description, date, '1' AS published , '1' AS approved FROM cas_phocagallery WHERE description REGEXP 'Oui' ;";

  $result = mysql_query ($query) or sql_error($query);
How to recover lost data in a query
===

I am using this query to duplicate title, description but the titles that are identical are deleted.
What is missing or wrongly coded?

	
$query = "CREATE TEMPORARY TABLE to_delete (title VARCHAR (200), min_id INT(4) NOT NULL);";

  $result = mysql_query ($query) or sql_error($query);



  $query = "INSERT INTO to_delete SELECT title, MIN(id) FROM cas_phocagallery GROUP BY title HAVING COUNT(*) > 1;";

  $result = mysql_query ($query) or sql_error($query);



  $query = "DELETE from cas_phocagallery WHERE EXISTS(SELECT min_id from to_delete WHERE to_delete.title = cas_phocagallery.title and to_delete.min_id != cas_phocagallery.id);";

  $result = mysql_query ($query) or sql_error($query);



  $query = "REPLACE INTO cas_phocagallery(title, catid, alias, filename, description, date,published,approved) SELECT title, '12' AS catid, alias, filename, description, date, '1' AS published , '1' AS approved FROM cas_phocagallery WHERE description REGEXP 'Oui' ;";

  $result = mysql_query ($query) or sql_error($query);