title: Update Parent table based on child records
body: <p>Hi all I want to update parent table's Status depend on child records.</p>
  
  <p>Condition is.</p>
  
  <blockquote>
    <p>Child records having the field <code>Isclosed</code>.</p>
  </blockquote>
  
  <ol>
  <li>if all child records <code>Isclosed=1</code> then Parent records status=1</li>
  <li>if some of the child records <code>Isclosed=1</code> then Parent records status=2</li>
  <li>else Parent records status=3</li>
  </ol>
  
  <p>Ihave tried this:</p>
  
  <pre><code>update Parent set Status=1
  where id in(
  select ParentID from Child where
  Isclosed=1  
   group by ParentID having count(id)=(select count(id)from Child where Parent.id=ParentID))
  </code></pre>
  
  <p>But it satisfy only 1 condition.</p>