title: How to write scripts with some logic between two tables in MySQL?
body: <p>Here's my questions in writing some scripts in MySQL:</p>
  
  <p>I get a table <code>T1</code> with some columns called id, <code>t1_col_01, t1_col_02</code>, and a table <code>T2</code> with some columns called <code>id, t2_col_01, t2_col_02</code>.</p>
  
  <p>For each row <code>R1</code> in <code>T1</code>, I want to update <code>R1.t1_col_01 = 'Yes'</code> if the there are multiple rows in <code>T2</code> that has the same <code>id</code> column with <code>R1.id</code>. If not, set <code>R1.t1_col_01 = 'No'</code>.</p>
  
  <p>I tried to write:</p>
  
  <pre><code>update T1, T2
  set
      T1.t1_col_01 = 'Yes'
  where
      (select count(*) from T2 where T2.id = T1.id) &gt; 1
  </code></pre>
  
  <p>But it didn't work. </p>