title: Is there any way to encrypt only data that are not encrypted yet?
body: <p>Is there any way to encrypt only data that are not encrypted yet?(Is there any way you can tell encrypted and non-encrypted data apart?)</p>
  
  <p>Please assume that I have a column that some data are already encrypted but some are not.</p>
  
  <p>Code for encrypt</p>
  
  <pre><code>update usersExample3 set password=aes_encrypt(password,'1234');
  </code></pre>
  
  <p>I have a stored procedure that I have to fix it but not sure how:</p>
  
  <pre><code>DELIMITER //
  
  CREATE PROCEDURE de ()
  LANGUAGE SQL
  DETERMINISTIC
  SQL SECURITY DEFINER
  COMMENT 'A procedure'
  BEGIN
   while(there is any not encrypted data in the table)
    --if(usersExample3.password is not encrypted yet)
         update usersExample3 set password=aes_decrypt(password,'1234');
    --else (do nothing)
  END//
  
  ;
  </code></pre>
  
  <p>Sample of my database:</p>
  
  <pre><code>select * from usersExample3 where userId&lt;=5;
  
  
  userId  username    password            salt
  1       Tom         Password1234        NULL
  4       bdfg        Î¸¨¾jj;öN/yë‘   bcv
  5       test        test                test
  </code></pre>
  
  <p>So here I want to update all data that are not encrypted yet(in this sample are userId 1 and 5.
  the problem is that everyone add data in database so when data saved in table, I have a trigger(after insert) that call this stored procedure to encrypt the new data automatically.
  Thanks</p>