Simcha Younger-2 wrote:
> If there is only one search term - "soup" your where statement would be:
>       Where `name` like 'soup'
> But you need two matches, and the terms are "soup", "vegetarian". Try:
>               Where GROUP_CONCAT('name') like 'soup'
>               AND GROUP_CONCAT('name') like 'vegetarian'
>               group by

You might be onto something, couldn't get your suggestion to work out the
box but after looking at the docs

Came the following

SELECT GROUP_CONCAT( SEPARATOR ' ') as tags, `taggings`.* FROM
 LEFT JOIN `taggings` ON ( = taggings.tag_id) WHERE ( IN
('vegetarian', 'soup')) GROUP BY taggings.taggable_id ORDER BY tags

Gives me two records but only one of them has both tags in the concat
column.  I can then pretty much do a length check on the tags column and see
when its less than the original input 

Wasn't aware of the DROUP_CONCAT function.  Cheers for pointing it out. 

View this message in context:
Sent from the Php - Database mailing list archive at

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to