[thelist] Simple table question...

Ken Schaefer Ken at adOpenStatic.com
Mon May 9 19:27:54 CDT 2005


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Jonathan Dillon
: Subject: RE: [thelist] Simple table question...
: 
: >On 5/9/05, Jonathan Dillon <jdillon at boehm-ritter.com> wrote:
: >> SELECT DISTINCT(email), firstname, lastname, phone FROM tablename;
: >>
: >> This is rather retarded, but why would this pull up duplicate emails?
: >> I just don't understand.  I thought DISTINCT would explicitly be
: >> distinct to the column name.
: >
: >What is it to do with the following data?
: >
: >joe at blow.com Joe Blow 555-555-5555
: >joe at blow.com Joe Blow 555-555-5556
: >
: >What row is it supposed to return?
: >
: >The reality is that every unique *combination* of fields listed after the
: DISTINCT keyword will be returned.
: 
: Matt:
: 
: Doh!
: 
: Yea, that's exactly what the data is doing.  So, would changing the order
: help?
: 
: SELECT firstname, lastname, phone, DISTINCT(email) FROM tablename;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not really

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
: How do you get around this seemingly simple problem?  I've got about 15%
: too many records!  I need records distinctly keyed 
: off their emails... ;-)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


You need to answer the following question. Given the following data, what
should be returned by your query?

joe at blow.com Joe Blow 555-555-5555
joe at blow.com Joe Blow 555-555-5556

When you answer that question, we can give you a query that meets your needs.

Cheers
Ken


More information about the thelist mailing list