title: Row Level Locking in Mysql
body: <p>I have 5 rows in a table (1 to 5). I want row 2 lock for some update and in the meanwhile if someone tries to update row 4, then he should able to update.</p>
  
  <p>I am trying this with code below, but I feel its placing lock on table level rather than row level.</p>
  
  <p>------ session 1</p>
  
  <pre><code>START TRANSACTION;
  SELECT * FROM test WHERE t=1 FOR UPDATE;
  UPDATE test SET NAME='irfandd' WHERE t=2;
  COMMIT;
  </code></pre>
  
  <p>----- session 2 (which is being blocked)</p>
  
  <pre><code>START TRANSACTION;
  UPDATE test SET NAME='irfandd' WHERE t=4;
  COMMIT;
  </code></pre>