Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
Select distinct
Old
  (#1)
UKuser
Guest
 
Posts: n/a
Default Select distinct - 06-04-2007, 07:50 AM

Hi Folks,

Is there a way to select one field distinctly but still return all the
others?

i.e.

Table
Name Address Tel
Test 123 Str 23456
Test 56 Str 21233
Hello 67 Town 232323

SELECT DISTINCT Name
But return in the query Address & Telephone as well

Not quite sure how this can be done.

Thanks

A

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Select distinct
Old
  (#2)
UKuser
Guest
 
Posts: n/a
Default Re: Select distinct - 06-04-2007, 07:50 AM

Hi again,

I have found the solution & hope you find this helpful

GROUP BY Name HAVING COUNT(DISTINCT Name)=1

Will fix the example problem.

A

UKuser wrote:
> Hi Folks,
>
> Is there a way to select one field distinctly but still return all the
> others?
>
> i.e.
>
> Table
> Name Address Tel
> Test 123 Str 23456
> Test 56 Str 21233
> Hello 67 Town 232323
>
> SELECT DISTINCT Name
> But return in the query Address & Telephone as well
>
> Not quite sure how this can be done.
>
> Thanks
>
> A


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top