使用php在mysql查询中查找重复项

时间:2017-06-27 13:01:10

标签: php mysql

我是PHP和MySQL的初学者。使用此查询信息,我如何添加代码以仅使用电话号码和名字,中间名和姓氏来查找重复的人。

$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);  

0 个答案:

没有答案