Welcome Guest, Not a member yet? Register   Sign In
Quick question regarding where_in/where_not_in Active Record
#4

[eluser]Darwin Survivor[/eluser]
Sorry to bump a 2 1/2 moth old post, but I have a similar question.

I'm making a photo gallery using tags and would like to run something like:
Code:
SELECT * FROM images WHERE images.id IN (SELECT image_id FROM tags WHERE tags.tag IN ('tag1', 'tag2', 'tag3'))

Basically, the user can select a list of tags, and the page will show all images which have been tagged with that tag.

The "tags" table holds a list of "tags to images". Each image can be in the table multiple times (each time with a different tag) and each tag can be applied to multiple images.

Everything in that query is static (non changing), except the list of tags (which can be any length).
Is there any easy way to do this is active directory, or would I need to create my own select statement?


Messages In This Thread
Quick question regarding where_in/where_not_in Active Record - by El Forum - 04-18-2009, 07:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB