View Single Post

  #2 (permalink)  
Old 05-15-2008
Captain Paralytic
 
Posts: n/a
Default Re: Indistinct results when using DISTINCT

On 15 May, 13:12, "petethebl...@googlemail.com"
<petethebl...@googlemail.com> wrote:
> Please can anyone explain this? I've tried to summarise the query so I
> hope I haven't fouled it up...
>
> I make this query:
>
> SELECT DISTINCT (
> c.`uid`
> ), c.fname, c.lname, d.`uid` AS id
> FROM tbl_c c, tbl_s s, tbl_d d
> WHERE c.`uid` = s.cust
> AND s.des = d.`uid`
> AND d.fab
> IN ( 5, 19, 29, 30, 31, 40 )
> AND d.created_date
> BETWEEN 20080501
> AND 20080519
>
> And yet the results are not distinct:
>
> uid,fname,lname,id
> 99027038 ,John ,Smith ,128136
> 99027038,John,Smith,129116
>
> Is this a bug? Or more likely, who can see my error?
>
> Thanks
>
> Pete

You seem to have superfluous brackets, around c.`uid`. These brackets
do not affect the query, they just don't do anything.
Apart from that, it looks to me like the 2 records are different. The
ID fields are not the same, so the query seems to be working
perfectly.
Reply With Quote