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 taggings.id
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(tags.name SEPARATOR ' ') as tags, `taggings`.* FROM
LEFT JOIN `taggings` ON (tags.id = taggings.tag_id) WHERE (tags.name 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 Nabble.com.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php