Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're going on the basis of tags, you'll just want a <code>WHERE tag = 'thistag'</code> condition (if there's one tag in the same table), or <code>WHERE tag in (SELECT tag FROM tags_table WHERE video_id = this_video_id)</code> if you normalise the tags out of your videos table, although either solution will probably return a lot of videos, so you'd have to prune it somehow.</p> <p>That's where it gets interesting (and difficult); you'd not only need to store a set of tags for each video, but also an affiliation score for each tag-to-video relationship. And that gets messy and subjective.</p> <p>On the other hand, if you really want the "most matched terms" (ask mentioned in your edit), what I really think you need is a <em>data mining query</em>. <a href="http://msdn.microsoft.com/en-us/library/dd299410.aspx" rel="nofollow noreferrer">Basket analysis</a> is the technique usually used to show "related items" when people are interested in looking at things that other people interested in <em>this</em> item are also interested in. That's a bit beyond a SQL query, but if you have SQL Server 2005, it's part of the Analysis Services package. Worth a look!</p> <p>Edit: now that you've posted the schema, I'd <em>strongly</em> suggest you normalise your <code>Tags</code> field into another table. It's very hard to code around a field that contains several delimited items, and is addressed by <a href="http://en.wikipedia.org/wiki/First_normal_form" rel="nofollow noreferrer">1st form normalisation</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload