Matches in a database.

JStay at mediageneral.com JStay at mediageneral.com
Tue Jun 28 11:59:02 MDT 2005


> On Tue, 2005-06-28 at 11:20 -0600, C. Ed Felt wrote:
> > 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.
> 
> I don't believe this is doable in a single query until MySQL 5.
> You /might/ be able to do it in 4.1, but I'm not sure.
> 

Sounds to me like you just want distinct records returned.  Would
something like this work?:

SELECT MAX(Record1), MAX(Record2), MAX(Etc) FROM CDR GROUP BY sessid
HAVING myDate > RequestedDate;

Or the DISTINCT statement might also do the trick:

SELECT DISTINCT Record1, Record2, Etc FROM CDR WHERE myDate >
RequestedDate;

Jesse



More information about the PLUG mailing list