[NBLUG/talk] OT - SQL query question

thiessen at sonic.net thiessen at sonic.net
Mon Dec 5 14:45:50 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.

You haven't used 'NAME' to label anything else in your database, have you?

Justin


>
> 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
>
> _______________________________________________
> talk mailing list
> talk at nblug.org
> http://nblug.org/cgi-bin/mailman/listinfo/talk
>





More information about the talk mailing list