RE: Delicious style Tags table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

Came the following

SELECT GROUP_CONCAT(tags.name SEPARATOR ' ') as tags, `taggings`.* FROM
`tags
 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: http://www.nabble.com/Delicious-style-Tags-table-tp19433010p19439195.html
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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux