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:47 AM

Hi Folks

Here is my SQL code:

SELECT *
FROM Company
INNER JOIN `Properties`
ON `Company`.`Company_ID`=`Properties`.`Company_ID`
WHERE `Properties`.`Property` LIKE '%$clean_search%'
ORDER BY Country
ASC

What I want this to return is a list of all fields: Company & Country
from the table Company. However its returning the same company multiple
times when there are more than 1 Properties.Property LIKE
$clean_search.

What I want but I'm not actually sure if it can be done is a statement
like:

SELECT DISTINCT Company, *

Can this 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)
Captain Paralytic
Guest
 
Posts: n/a
Default Re: Select distinct - 06-04-2007, 07:48 AM


UKuser wrote:

> Hi Folks
>
> Here is my SQL code:
>
> SELECT *
> FROM Company
> INNER JOIN `Properties`
> ON `Company`.`Company_ID`=`Properties`.`Company_ID`
> WHERE `Properties`.`Property` LIKE '%$clean_search%'
> ORDER BY Country
> ASC
>
> What I want this to return is a list of all fields: Company & Country
> from the table Company. However its returning the same company multiple
> times when there are more than 1 Properties.Property LIKE
> $clean_search.
>
> What I want but I'm not actually sure if it can be done is a statement
> like:
>
> SELECT DISTINCT Company, *
>
> Can this be done?
>
> Thanks
>
> A


Try:

SELECT DISTINCT `Company`.*
FROM `Company`
INNER JOIN `Properties` USING(`Company_ID`)
WHERE `Properties`.`Property` LIKE '%$clean_search%'
ORDER BY Country ASC

   
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