many-to-many query
Posted
by kofto4ka
on Stack Overflow
See other posts from Stack Overflow
or by kofto4ka
Published on 2010-04-27T20:37:56Z
Indexed on
2010/04/27
20:43 UTC
Read the original article
Hit count: 358
Hello, guys! I have a problem and I dont know what is better solution. Okay, I have 2 tables: posts(id, title), posts_tags(post_id, tag_id). I have next task: must select posts with tags ids for example 4, 10 and 11. Not exactly, post could have any other tags at the same time. So, how I could do it more optimized? Creating temporary table in each query? Or may be some kind of stored procedure? In the future, user could ask script to select posts with any count of tags (it could be 1 tag only or 10 at the same time) and I must be sure that method that I will choose would be the best method for my problem. Sorry for my english, thx for attention.
© Stack Overflow or respective owner