So I am having difficulty thinking of how to make this select query. I have
two tables that mimic tags similar to flickr, delicious etc. They are
defined below
CREATE TABLE IF NOT EXISTS `taggings` (
`id` int(11) unsigned NOT NULL auto_increment,
`tag_id` int(11) NOT NULL,
`taggable_id`
SELECT `tags`.*, count(taggable_id) as cnt, `taggings`.* FROM `tags`
JOIN `taggings` ON tags.id = taggings.tag_id WHERE (name IN ('vegetarian',
'soup', 'lunch', 'curry')) group by taggable_id
Evert Lammerts-2 wrote:
>
> Your 'taggings' table is basically a link table to deal with a 'many
> to
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_CONC
Simcha Younger-2 wrote:
>
>
> I did a little testing, and this should work better:
>
> Select...
> From...
> group by taggings.id
> HAVING GROUP_CONCAT('name') like 'soup'
> AND GROUP_CONCAT('name') like 'vegetarian'
>
>
Yep, that works also, just to clarify it needed %'s either side to wor