title: SQL to produce matches from a data table and a pattern table
body: <p>Given a data table with columns id, color, size and a second table with rules/patterns so rule_id, color_condition and size_condition.</p>
  
  <p>So a basic rule would be rule_id=1,Color=blue, size=Any or rule_id=2,Color=blue, size=15</p>
  
  <p>How can I construct a SQL query that produces matches into a third table</p>
  
  <p>For example for an entry in the data table id=1, color=blue, size=10 both rules would apply and therefor the matches table would cotain two entries</p>
  
  <pre><code>rule_id=1, entry_id=1
  rule_id=2, entry_id=1
  </code></pre>
  
  <p>How To cycle through the patterns and how to construct the matching so that it can deal with wildcards or omit conditions if they are empty.</p>
  
  <p>Please provide directions or keywords, I am ready to read.</p>