title: Building lists in sql
body: <p>I need to build a list from a couple of tables and I can't seem to work out how to build it.</p>
  
  <p>I have a table with bike models and a products table:</p>
  
  <p><strong>bikes</strong></p>
  
  <pre><code>modelno, franchise, description, year,profile
  "1","kawasaki","ninja","2009","1-2009"
  "2","honda","cbr600","2006","2-2006"
  </code></pre>
  
  <p><strong>products</strong></p>
  
  <pre><code>productid, category, profile,
  "1","carburettor",",1-2009,",
  "2","Generic Gear Lever",",1-2009,2-2006,"
  </code></pre>
  
  <p>the profile field holds a comma delimited list of all the vehicles the part fits.</p>
  
  <p>i can get a list to work for one vehicle by using:</p>
  
  <pre><code> SELECT
     (SELECT Franchise + ' ' + 
             description + ' ' + 
             year as model from bikes where profile = @model + '-' + 
             @year
     ) 
   as model, catalogueref, tier2
   FROM products
   WHERE profile LIKE '%,' + @model + '-' + @year + ',%'`
  </code></pre>
  
  <p>which gives me:</p>
  
  <pre><code>bike, lever, sprocket, etc...
  kawasaki 250 2009, 123456,234567, etc...
  </code></pre>
  
  <p>However, I need to perform this function on around 8000 models, and would rather not have to do each one individually. Is there any way I could make it take a list of profiles?</p>