title: How to get COUNT from several tables?
body: <p>I have these data below</p>
  
  <pre><code>TABLE 1   SID   CAMBORROW      OTMARK
            S1      CAM1           1
            S2      CAM2           1
            S3      CAM3           0
  
  TABLE 2   SID   BOOKBORROW     OTMARK
            S1     book1           1
            S2     book2           0
            S3     book3           0
  
  TABLE 3   SID     NAME           
            S1     SNAME1
            S2     SNAME2
            S3     SNAME3
  </code></pre>
  
  <p>Now what I want to do is getting how many times does this person have OTMARK 1 on him/her, also group by his/her name. This is what I use for the query.</p>
  
  <pre><code>SELECT TABLE3.NAME,COUNT(*)
  FROM TABLE1,TABLE2,TABLE3
  WHERE TABLE3.SID = TABLE1.SID
  AND   TABLE1.OTMARK = 1
  OR( TABLE3.SID = TABLE2.SID
     AND TABLE2.OTMARK = 1)
  GROUP BY TABLE1.NAME
  </code></pre>
  
  <p>The result I got is far wrong than what should happen. I don't know which part I got it wrong, so I need help. Thank you in advance.</p>
  
  <p>EDIT: The expect output is </p>
  
  <pre><code>SNAME   COUNT
  SNAME1   2
  SNAME2   1
  </code></pre>