[NBLUG/talk] OT - SQL query question

Mark Street mark at oswizards.com
Mon Dec 5 13:16:30 PST 2005


This is really strange, I ran

SELECT DISTINCT `ADDR1`,`CITY`,`STATE`,`ZIPCODE` from mydb;

the query works as expected, returning roughly 7000 records of the initial 
12000, which is what I am expecting.

If I place the `NAME` field either after ADDR1 or ZIPCODE the query does not 
work as expected and returns multiple instances of the ADDR1 records, not 
DISTINCT.

On Monday 05 December 2005 12:57 pm, Troy Arnold wrote:
> I think a simple GROUP BY clause will get you what you want (since it
> doesn't seem you're particular about which specific rows with ADDR1 you
> get back)
>
> select * from table group by ADDR1

I will try this and see, you are correct, I really don't care which ADDR1 row 
is returned as long as they are all unique.
-- 
Mark Street, RHCE
http://www.oswizards.com
--
Key fingerprint = 3949 39E4 6317 7C3C 023E  2B1F 6FB3 06E7 D109 56C0
GPG key http://www.oswizards.com/pubkey.asc



More information about the talk mailing list