MySQL Forums :: Newbie :: using GROUP_CONCAT


Advanced Search

using GROUP_CONCAT
Posted by: phil kirkman ()
Date: March 11, 2009 10:17AM

I have a select query running from a search, dog by breed, where dogs is my main table, breeds is my breed table with a junction table dog_breed for the many to many relationship.

$breed = $_POST['breed'];



$query="
SELECT
dogs.dogID,
dogName,
sex,
young,
other,
dogDesc,
GROUP_CONCAT(
breeds.breed SEPARATOR ', '
)
AS dogBreeds,
sheltName
FROM
dogs,
dog_breed,
breeds,
shelters
WHERE
dogs.dogID = dog_breed.dogID
AND dog_breed.breedID = breeds.breedID
AND dogs.sheltID = shelters.sheltID
AND breeds.breed LIKE '%".$breed."%'
GROUP BY dog_breed.dogID
";

However, when I search on breed it's only returning the distint breed from the breeds table (e.g. 'dobermann' instead of 'dobermann, retriever'). I can't seem to find a workaround - I hope this makes sense as I'm a complete beginner at this. Thanks.

Options: ReplyQuote


Subject Written By Posted
using GROUP_CONCAT phil kirkman 03/11/2009 10:17AM
Re: using GROUP_CONCAT Rick James 03/12/2009 09:35AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.