Tuesday, 20 June 2017

Finding Duplicates in mysql query using php

I'm a beginner in PHP and MySQL. Using this query information how can I add code to find duplicate people using only Phone Number and First name, middle initial and last name.



$query = "SELECT id, first_name, last_name, mi, organization, ";  
$query.= "primary_email, second_email, primary_phone, ";
$query.= "address1, address2, city, state_province, zip, ";
$query.= "last_login ";
$query.= "FROM member_tbl WHERE id < 1000"; // *change to "WHERE status = 'ACTIVE'" -- but that causes a fatal memory error*

$stmt = $pdo->prepare($query);

$stmt->execute();


$mbrTbl = $stmt->fetchAll(PDO::FETCH_ASSOC);
for($i=0; $i<$stmt->rowCount(); $i++) {
*// Gather all the info for one member*
$fName1 = strtolower($mbrTbl[$i]['first_name']);
$lName1 = strtolower($mbrTbl[$i]['last_name']);
$mName1 = strtolower($mbrTbl[$i]['mi']);
$phone1 = $mbrTbl[$i]['primary_phone'];

$org1 = strtolower($mbrTbl[$i]['organization']);
$primEmail1 = strtolower($mbrTbl[$i]['primary_email']);
$scndEmail1 = strtolower($mbrTbl[$i]['second_email']);
$phone1 = $mbrTbl[$i]['primary_phone'];
$address11 = strtolower($mbrTbl[$i]['address1']);
$address21 = strtolower($mbrTbl[$i]['address2']);
$city1 = strtolower($mbrTbl[$i]['city']);
$state1 = strtolower($mbrTbl[$i]['state_province']);
$zip1 = $mbrTbl[$i]['zip'];
}

print_r($mbrTbl);

No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...