Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: SQL Results

by Speedy (Monk)
on Feb 12, 2002 at 04:39 UTC ( [id://144782]=note: print w/replies, xml ) Need Help??


in reply to SQL Results

If you use a hash technique to remove duplicates, be careful of the case. Otherwise John@isp.net will be different from john@isp.net, and John john will get two copies of the email.

When saving email addresses from Web forms I generally make the stored results lower case.

Replies are listed 'Best First'.
Re: Re: SQL Results
by theorbtwo (Prior) on Feb 12, 2002 at 13:17 UTC
(jeffa) 2Re: SQL Results
by jeffa (Bishop) on Feb 12, 2002 at 15:29 UTC
    Most correct about case!

    Here is one way to elimate 'would-be' duplicates who simply are not because of case sensitivity:

    use strict; my %unique; my @email = qw( John@foo.com john@foo.com CAPTELO@microshaft.con CAPTELO@microshaft.com captntenille@muskrat.com CaPtNtEnIlLe@muskrat.com ); for (@email) { my $key = lc $_; $unique{$key} = $_ unless ($unique{$key} and $unique{$key} =~ /[A-Z +]/); } print join("\n", values %unique), "\n";
    Yields the list:
    CAPTELO@microshaft.com
    CaPtNtEnIlLe@muskrat.com
    CAPTELO@microshaft.con
    John@foo.com
    
    Of course, this is NOT perfect. Just some random thoughts if you will. ;) If you are not concerned with the extra overhead of space, i recommend storing the email address twice: once as it is, and once all lower-cased. Then you could issue a SQL statement like:
    SELECT distinct lc_email, email, ...
    
    and only use the 'email' column. Actually, even better might be performing a comparison before you insert the email address - make sure that a lower case version of the candidate email address does not already exist in the database first.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://144782]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-05-30 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found