title: mysql update if all values not exists in same table else nothing
body: <p>I have a Table With multiple columns existing data already like</p>
  
  <pre>
  +------+------+--------------+------+---------+
  | id   | ref  |name          |role  | status  |
  +------+------+--------------+------+---------+
  |    1 |   ab |Faizal        |adm   | 1       |
  |    2 |   ab |Faizal        |      | 0       |
  |    3 |   cd |Faizal        |usr   | 1       |
  |    4 |   am |Agrim         |usr   | 1       |
  |    5 |   xy |vishal        |usr   | 1       |
  |    6 |   xy |vishal        |usr   | 0       |
  |    7 |   ad |ankush        |usr   | 1       |
  |    8 |   ad |ankush        |      | 0       |
  |    9 |   mm |vishal        |oth   | 1       |
  +------+------+--------------+------+---------+
  </pre>
  
  <p>and I don't want assign a role to a user multiple time in table,Update should take action only when in the table <strong>user</strong> haven't the same <strong>role</strong> with same <strong>status</strong>. Like I tried that query</p>
  
  <pre><code>UPDATE roles t1
  SET
    t1.role   = 'adm',
    t1.status = '1',
    t1.ref    = 'ab'
  WHERE t1.id = 2 AND NOT EXISTS
  (
      SELECT 1
      FROM roles t2
      WHERE t1.role = t2.role
            AND t1.status = t2.status
            AND t1.ref = t2.ref
  )
  </code></pre>
  
  <p><strong>It Gives an Error</strong>
  I want after executing the query:</p>
  
  <pre>
  +------+------+--------------+------+---------+
  | id   | ref  |name          |role  | status  |
  +------+------+--------------+------+---------+
  |    1 |   ab |Faizal        |adm   | 1       |
  |    2 |   ab |Faizal        |      | 0       |
  |    3 |   cd |Faizal        |usr   | 1       |
  |    4 |   am |Agrim         |usr   | 1       |
  |    5 |   xy |vishal        |usr   | 1       |
  |    6 |   xy |vishal        |usr   | 0       |
  |    7 |   ad |ankush        |usr   | 1       |
  |    8 |   ad |ankush        |      | 0       |
  |    9 |   mm |vishal        |oth   | 1       |
  +------+------+--------------+------+---------+
  </pre>
  
  <p><strong>nothing Changed</strong> Because the given key data is already exist in table.</p>
  
  <hr>
  
  <p><strong>Another Example:</strong>
  Run the query with other key data.</p>
  
  <pre><code>UPDATE roles t1
  SET
    t1.role   = 'adm',
    t1.status = '1',
    t1.ref    = 'ad'
  WHERE t1.id = 8 AND NOT EXISTS
  (
      SELECT 1
      FROM roles t2
      WHERE t1.role = t2.role
            AND t1.status = t2.status
            AND t1.ref = t2.ref
  )
  </code></pre>
  
  <p>after the executing the query table should :</p>
  
  <pre>
  +------+------+--------------+------+---------+
  | id   | ref  |name          |role  | status  |
  +------+------+--------------+------+---------+
  |    1 |   ab |Faizal        |adm   | 1       |
  |    2 |   ab |Faizal        |      | 0       |
  |    3 |   cd |Faizal        |usr   | 1       |
  |    4 |   am |Agrim         |usr   | 1       |
  |    5 |   xy |vishal        |usr   | 1       |
  |    6 |   xy |vishal        |usr   | 0       |
  |    7 |   ad |ankush        |usr   | 1       |
  |    8 |   ad |ankush        |      | 0       |
  |    9 |   mm |vishal        |oth   | 1       |
  +------+------+--------------+------+---------+
  </pre>
  
  <p>Keep in mind Conditions:</p>
  
  <ol>
  <li>We can't INSERT or DELETE in table. </li>
  <li>Can't update the rows where status=1</li>
  </ol>