MySQL Forums
Forum List  »  InnoDB

Query with DISTINCT - logic?
Posted by: P. Boomer
Date: November 17, 2008 11:35AM

I've got a small query going that looks basically like this:

SELECT * from `mydb` WHERE `IDENTIFIER` = $variable

The $variable contains a value the user chooses from a coded dropdown.

The database I am working with contains multi-thousands of entries - BUT - there are many duplicate entries where ONLY one field (EMAIL) is different from the rest:

EMAIL ADDRESS COMPANY NAME STREET IDENTIFIER
joe@acme.com 23 Elm Street Acme Investing San Diego 12345
john@blarney.com 90 Oak Street Blarney Capital Berkeley 12345
fred@blarney.com 90 Oak Street Blarney Capital Berkeley 12345
mary@blarney.com 90 Oak Street Blarney Capital Berkeley 12345

I want to select all records, where `IDENTIFIER` = '12345', AND
which have a unique address. The problem is that the database has many listings at a single addresses, and I only want one record per address.

I think I could write this if I could figure out the logic!

TIA for your usual expertise!

Options: ReplyQuote


Subject
Views
Written By
Posted
Query with DISTINCT - logic?
3194
November 17, 2008 11:35AM
2077
November 18, 2008 10:21AM
2024
November 19, 2008 12:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.