Matches in a database.

C. Ed Felt edfelt at
Tue Jun 28 11:20:53 MDT 2005

Fellow Open Software Supporters:

I would like to ask for some input on a database issue I am working on. 

I am getting repeat records in my billing database for a VoIP company.  
There is no fix for this as it is a SIP, (Session Initiation Protocol), 
specific problem so I am working on a post process solution.

I am writing a script in Python and the database is MySQL.  The 
programming language doesn't matter since I am only looking for a 
suggestion on my sql (MySQL) query.  My current plan is to pull all 
records (called Call Data Records or CDRs) from the database for the 
last 24 hours in to a big array.  If any of the records match on a field 
called 'sessid' then they are copies (though not exact copies as there 
can be timestamp differences). 

So, in short, (since a paragraph will get confusing):

1.  SELECT all records in the CDR table after a requested date (usually 
24 hours).
2.  Store these records in a huge array.
3.  Find all repeats on the 'sessid' field and store this in an array.
4.  Delete all repeats (save one copy of each repeat CDR).

Is there a MySQL query, (version 3), to select all rows that have one or 
more matching rows on a specific field ('sessid')?  This would 
essentially combine steps 1, 2 and 3 in one MySQL query.


Ed Felt

More information about the PLUG mailing list