title: Stored procedure to update the count
body: <p>I have the below 2 SQL tables</p>
  
  <pre><code>Table 1
  Id | Data | Values
  1  | rfsd | 23
  2  | tfgy | 45
  3  | rfff | 23
  
  
  Table 2
  
  Id | Fields | Counts
  1  | 23     |   0 
  2  | 45     |   0
  </code></pre>
  
  <p>As you can see, the Counts field is 0. I want to see 'Fields' column in table 2 and compare then with the 'Values' column in table 1 and increment the count whenever the value is present in 'Values' field.</p>
  
  <p>The final result should show like this</p>
  
  <pre><code>Table 2
  Id | Fields | Counts
  1  | 23     |   2
  2  | 45     |   1
  </code></pre>
  
  <p>This will be the counts since 23 appear twice and 45 appear once in the 'Values' field of table 1.</p>
  
  <p>Can someone please let me know how to write a stored procedure for this. </p>