Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Welcome to the Monastery
 
PerlMonks  

(jeffa) 2Re: SQL Results

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.