newbie: tags (or habtm) howto?

I there some place that has a good walk through on implementing

Basically, I have a table of things a table of tags. the things have a
many-to-many relationship to tags. I can get tags for a thing by
thing.tags but i'm at a loss as to how to get things back that are
tagged with multiple tags --

ie. if i were writing sql:

SELECT thing_id
FROM thing
    JOIN thing_tag AS thing_tag_1 ON (thing.thing_id =
    JOIN tag AS tag_1 ON (thing_tag_1.tag_id = tag_1.tag_id)
    JOIN thing_tag AS thing_tag_2 ON (thing.thing_id =
    JOIN tag AS tag_2 ON (thing_tag_2.tag_id = tag_2.tag_id)
WHERE tag_1.tag = 'foo'
    AND tag_2.tag = 'bar'

help!! thanks!

Thanks, Elad. It seems like there's some question as to whether to use
the gem or the plug-in. Any thoughts?

FYI, for anyone else dickering around with this sort of thing, I found
this helpful:

Intersection (AND)
Query for "bookmark+webservice+semweb":
FROM scBookmarks b, scCategories c
WHERE c.bId = b.bId
AND (c.category IN ('bookmark', 'webservice', 'semweb'))

the having count() thing is cute.

I currently use the acts_as_taggable plugin because I need to tag
stuff on multiple tables and if you use the gem version you need a
taggings tables for each one of those tables. So if you need to tag a
lot of different I'd go with the plugin, or else the gem which has
some goodies built-in like tags cloud.

Unfortunately, both seem to be have no more development at all :frowning: