List:General Discussion« Previous MessageNext Message »
From:Paul Nowosielski Date:August 18 2008 11:08am
Subject:sub query help
View as plain text  
Dear All,

I am interested in performing a sub query that  removes duplicate records from
a temporary table prior to pushing the data to the main table.

I am not sure if it is possible and thought I would ask prior to the endeavor.

I currently use php to perform this operation but is really bogs down the db.

Here is the code example i am using now to perform this function:

// select the name from the dedup row

$sql = "select name,id from dedup";

$ret = run_query($sql);

// loop through and check if the name exists in the lead table


        $sql2 = "select name,id from leads where name LIKE '$ddupRow[name]'";
        $ret2 = run_query($sql2);

     // if rows returned is greater than 0 delete from the dedup table

        if(myqsl_num_rows( $ret2 ) > 0){

            $del_sql = "DELETE FROM dedup WHERE id = '$ddRow[id]'";

       // else insert the new record

        $iQ="INSERT into leads (name) VALUES ( '$ddupRow[name]')";
;       run_query($iQ);

I am wondering if it is possible to do this with one query without the double hit to the
Or ,if possible, perform one large query and remove the duplicates in one blow?

Any thought or suggestions would be very much appreciated.

Kind Regards,


sub query helpPaul Nowosielski18 Aug