title: How to create Mysql unix_timestamp with millisecond
body: <p>I have a php function using mysql query UNIX_TIMESTAMP() to create a unique transaction number, but I found that if the function loop in same time, it will generate the same transaction number for Case 1, using Case 2 is not a good way for huge loop.</p>
  
  <p>1.I am using transaction number is for sorting same transaction date in table list.</p>
  
  <p>2.My transaction table is using UUID as PK, because data cross DB.</p>
  
  <p><strong>Desire answer is like below and unique.</strong></p>
  
  <pre><code>TransNo = 1397533879.20290
  </code></pre>
  
  <p>PHP Version 5.3</p>
  
  <p>Mysql Version 5.5</p>
  
  <p>E.g. Function Loop 3 times</p>
  
  <p><strong>Case 1 :</strong></p>
  
  <pre><code>SELECT UNIX_TIMESTAMP() as TransNo;
  
  Output : 
  1397533879
  1397533879
  1397533879
  </code></pre>
  
  <p><strong>Case 2 :</strong></p>
  
  <pre><code>SELECT UNIX_TIMESTAMP() as TransNo, SLEEP(1);
  
  Output :
  1397533879
  1397533880
  1397533881
  </code></pre>