title: INSERT INTO and the subquery with COUNT
body: <p>I'd like to put photo data to the table <code>articles_photos</code> and condition it with numbers of photos for selected article.</p>
  
  <p>Both tables exist. Below I have presented my query</p>
  
  <pre><code>INSERT INTO articles_photos(title, 
                              filename, 
                              photo_order, 
                              created, 
                              article_id) 
        VALUES ('title', 
                'filename', 
                 (SELECT COUNT(id) 
                    FROM articles_photos 
                   WHERE article_id = 7) + 1, 
                NOW(), 
                7)
  </code></pre>
  
  <p>phpmyadmin says:</p>
  
  <pre><code>Static analysis:
  
  5 errors were found during analysis.
  
      A comma or a closing bracket was expected (near "SELECT" at position 109)
      Unrecognized keyword. (near "COUNT" at position 116)
      Unexpected token. (near "(" at position 121)
      Unexpected token. (near "id" at position 122)
      Unexpected token. (near ")" at position 124)
  
  #1093 - Table 'articles_photos' is specified twice, both as a target for 'INSERT' and as a separate source for data
  </code></pre>
  
  <p>What did I wrong?</p>