title: Select blog articles by tag
body: <p>I have a custom working blog. Everything works fine I was just wondering if anyone knows of a better way to select articles containing tags from a mysql database.</p>
  
  <p>Currently the tags are stored in the "blog" table, under "blog_tags" and the articles are retreaved using LIKE '%tag%'. I this worked fine until I had 2 tags containing the same word e.g. website and website design. </p>
  
  <p>Using the above method by searching for tags like website I would get the results containing the website tag and website design.</p>
  
  <p>To fix the solution I added "*" at the beginning and end of each tag so blog_tags now looks like *tag 1*, *tag 2*, *tag 3*, *And so on...</p>
  
  <p>Now I just search for articles with blog_tags like '%*tag here*%'. This works perfectly but there is probably a better way. Any ideas?</p>
  
  <p>The query currently used is:</p>
  
  <pre><code>"SELECT * FROM `blog` WHERE `active` = 'y' AND `blog_tags` LIKE '%*" . str_replace("-", " ", $tag) . "*%' ORDER BY `blog_created` DESC LIMIT " . $startfrom . "," . $limit
  </code></pre>
  
  <p>Thank in advance!</p>