Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

(jeffa) 2Re: SQL Results

by jeffa (Bishop)
on Feb 12, 2002 at 15:29 UTC ( [id://144877]=note: print w/replies, xml ) Need Help??


in reply to Re: SQL Results
in thread SQL Results

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://144877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2025-07-15 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.