mysql - How to retrieve multiple tags from a database? -


alright, have done research , found out normalized articles , tags table should this:

articles table:  article_id | article_text  tags table: tag_id | tag_text  article-tag table: article_id | tag_id 

now, try this: let's searching 3 tags example, "asp.net", ".net", "c#". easy retrieve articles has these tags. don't want this. want retrieve articles has exactly these 3 tags or any 2 or 1 of them not articles 4 or more tags including them. don't want search result "asp.net", ".net", "c#", "ruby". want following tagged articles:

"asp.net", ".net", "c#"  .net", "c#"  "asp.net", ".net"  "asp.net", "c#"  "c#"  "asp.net"  ".net" 

what right mysql query that?

i'm thinking self join might way. if querying 3 tags, join article-tag table 3 times, example. i'm not sure how scale, though.

update: approach need second query exclude matches > 3 tags.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -