This is a discussion on Select distinct within the MySQL forums, part of the Database Server Software category; --> Hi Folks Here is my SQL code: SELECT * FROM Company INNER JOIN `Properties` ON `Company`.`Company_ID`=`Properties`.`Company_ID` WHERE `Properties`.`Property` LIKE ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| ||||
| 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 |