Current location: Hot Scripts Forums » Programming Languages » PHP » displaying all duplicate records in my table.


displaying all duplicate records in my table.

Reply
  #1 (permalink)  
Old 08-24-03, 09:54 PM
dsumpter dsumpter is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Huntington Beach, CA
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
displaying all duplicate records in my table.

Please help!!! I am trying to now clean up my database of customers that contains duplicates. I would like to be able to display all records that have the same email address fieldname "targetEmail" and client ID "clientID"... then delete certain ones that I select.

Does anyone know how I can do the display portion of this? Thanks in advance for your help...

Dan
__________________
Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-28-03, 03:24 AM
ChristGuy ChristGuy is offline
Operations Support Develo
 
Join Date: Jun 2003
Location: Rivonia, South Africa
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Greetingz...

Please could you post your table structure Including Indexes...

My Solution isn't PHP but MySQL Based... (Basically Tightening your Indexes to not allow duplicates...)
__________________
Till We Meet Again...
Clifford W. Hansen
Aspivia (Pty) Ltd

"We Have Seen Strange Things Today!" Luke 5:26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-28-03, 06:48 AM
ermau's Avatar
ermau ermau is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Florida, USA
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, you should have clientID as primary, indexed and auto_increment so it doesn't duplicate.
__________________
PHP / mySQL Developer
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-28-03, 11:34 AM
dsumpter dsumpter is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Huntington Beach, CA
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for your reply's guys... I know how to designate fields as unique in MySQL, but my problem is that there are currently duplicate records and I can't just eleminate based upon one field in the table.

I need to be able to allow duplicates of the targetEmail field, because the same person can be registered with multiple clientID's.

What do you think about a way to display all records that have both the same targetEmail and clientID?

I found one idea on a message board, but cant get it to work. Let me know what you think... Thanks again for your help guys!!!

http://www.15seconds.com/issue/011009.htm


----------------------------
My Table structure is below...

# phpMyAdmin MySQL-Dump
# version 2.2.6
# http://phpwizard.net/phpMyAdmin/
# http://www.phpmyadmin.net/ (download page)
#
# Host: localhost
# Generation Time: Aug 28, 2003 at 08:37 AM
# Server version: 3.23.55
# PHP Version: 4.2.2
# Database : `aci`
# --------------------------------------------------------

#
# Table structure for table `target`
#

CREATE TABLE target (
targetID int(11) NOT NULL auto_increment,
targetEnteredDate varchar(8) NOT NULL default '0',
targetEmail varchar(50) default NULL,
targetFirstName text NOT NULL,
targetLastName text,
targetStreetAddress varchar(50) default NULL,
targetCity text,
targetState text,
targetZip varchar(11) default '0',
targetFirstTimeCustomer text NOT NULL,
targetBirthday1 varchar(4) default NULL,
targetBirthday1Name text,
targetBirthday2 varchar(4) default NULL,
targetBirthday2Name text,
targetBirthday3 varchar(4) default NULL,
targetBirthday3Name text,
targetBirthday4 varchar(4) default NULL,
targetBirthday4Name text NOT NULL,
targetBirthday5 varchar(4) default NULL,
targetBirthday5Name text NOT NULL,
targetAnniversary varchar(4) default NULL,
clientID int(11) NOT NULL default '0',
targetAdType text,
targetSpecialInterest1 text,
targetSpecialInterest2 text,
targetSpecialInterest3 text,
targetSpecialInterest4 text,
targetSpecialInterest5 text,
targetSpecialInterest6 text,
targetOther1 text,
targetOther2 text,
targetBillAmount int(11) default NULL,
targetServer varchar(25) default NULL,
targetFTEmailSent char(1) default NULL,
PRIMARY KEY (targetID),
KEY clientID (clientID)
) TYPE=MyISAM;
__________________
Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-01-03, 07:16 AM
ChristGuy ChristGuy is offline
Operations Support Develo
 
Join Date: Jun 2003
Location: Rivonia, South Africa
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Greetingz...

I've been unable to get to that site: http://www.15seconds.com/issue/011009.htm

If you could could you please e-mail it to me...

also from your last message... Indexes won't solve your problem... unless you only have one entry per person...

not more than one like you said you'd need?
__________________
Till We Meet Again...
Clifford W. Hansen
Aspivia (Pty) Ltd

"We Have Seen Strange Things Today!" Luke 5:26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-02-03, 11:32 AM
dsumpter dsumpter is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Huntington Beach, CA
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
go to http://dsumpter.com/15seconds.pdf

I don't fully understand what the guy in this article is doing, but it sounds like the end result is kinda like what I want to do.

My biggest thing is that I just want to be able to display all records that have the same targetEmail, and clientID.

What do you think?

Thanks man...
Dan
__________________
Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 09-02-03, 11:54 AM
ChristGuy ChristGuy is offline
Operations Support Develo
 
Join Date: Jun 2003
Location: Rivonia, South Africa
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Greetingz...

Thanx for the PDF...

Because MySQL < 4.1 can't do Sub Selects We'll haveto try something different...
(This hasn't been tersted but should work)
PHP Code:

  $dbConn MySQL_Connect"localhost""root""" ) or

    Die( 
"Error connecting to MySQL: " MySQL_Error() );

  
MySQL_Select_DB"aci" ) or
    Die( 
"Error selecting Database: " MySQL_Error() );

  
$sSQL "SELECT DISTINCT clientID, targetEmail FROM target";  //  Select Unique values

  
$resUnique MySQL_Query$sSQL ) or
    Die( 
"Error executing query: " MySQL_Error() );

  while ( 
$row MySQL_Fetch_Array$recUnique ) )
  {
    
$sSQL "SELECT * FROM target WHERE clientID=" $row["clientID"] . " AND targetEmail=" $row["targetEmail"];

    
$recDuplicate MySQL_Query$sSQL ) or
      Die( 
"Error executing query: " MySQL_Error() );

    while ( 
$duplicates MySQL_Fetch_Array$recDuplicate ) )
    {
      print( 
"Duplicate found: " $duplicates["clientID"] . "<BR>\n" );
    }

    
MySQL_Free_Result$recDuplicate );
  }

  
MySQL_Free_Result$recUnique );
  
MySQL_Close$dbConn ); 
Like I said I havn't tested the above... But I'm quite sure it will work as is...
__________________
Till We Meet Again...
Clifford W. Hansen
Aspivia (Pty) Ltd

"We Have Seen Strange Things Today!" Luke 5:26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validator ctrl in table cell : Strange behaviour sunny_doncaster ASP.NET 6 07-31-08 10:43 AM
Autonum in mysql table pk_jsp PHP 1 10-11-03 05:32 PM
moving data from table to table ..please help! geneane ASP 2 09-22-03 08:02 PM
type mismatch and update loop - HELP! seala ASP 1 09-22-03 06:27 PM
LOTS of duplicate entries KingSky HotScripts Site Bug Reports 0 06-17-03 11:09 AM


All times are GMT -5. The time now is 12:43 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.