title: Mysql, insert based on condition of select
body: <p>I need to execute complex query with insert based on select comparison of number of rows and value of that rows.
  Here what I want to do:
  - select from table "media" all the media with specific "post_id"
  - check if all rows have "media_status" set to active
  - if yes update in table "media" the value of "posts_status" to "active"</p>
  
  <p>Is it possible to do it in one query?</p>
  
  <pre><code>async.waterfall([
          function download(next) {
              // pick media
              },
          function transform(response, next) {
              // transcode media
          },
          function upload(next) {
              // upload transcoded
              },            
          function clean(response, next) {
              // clean temp
  
              },
          function connectDb(next) {
              // connect to db
              },
          function saveDb(next) {
              // save single media
              },
          function conditionalNotification(next) {
              // HERE I NEED TO CHECK IF ALL MEDIA ARE TRANSCODED AND SET POST_STATUS ACTIVE 
              }             
              ...
  
  </code></pre>