Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unique Results Only 1

Status
Not open for further replies.

CzechNET

Programmer
Nov 2, 2004
28
0
0
CA

I have a query like this:

SELECT fldUSERNAME, fldPASSWORD, fldNAME, fldEMAIL FROM MY_TABLE

Now I'm trying to return only those records with a unique email addres, so no email address would be repeated twice.
How would I go about it, somehow use the GROUP BY ?
 
Code:
select fldUSERNAME
     , fldPASSWORD
     , fldNAME
     , fldEMAIL 
  from MY_TABLE as foo
 where 1 
     = ( select count(*)
           from MY_TABLE
          where fldEMAIL 
              = foo.fldEMAIL )
this is probably not what you really want, but it is exactly what you asked for

:)

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
Thanks Rudy :) I think it's exactly what I was after, it gives me the fields I need but only form records that have a unique email address. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top