title: SQL Query to Insert a column value which treat as reference ID
body: <p>Hello friends I know its a silly question. But my mind is stop working and I am stuck at this position.If anyone having any solution for this question please help me.</p>
  
  <p>I want solution  for both  <code>Mysql</code> as well as <code>SQL Server</code></p>
  
  <p>I have a table called refference having structure</p>
  
  <pre><code>id          int(10)     AUTO_INCREMENT   
  reff_id     varchar(100)         
  pid         int(11)         
  </code></pre>
  
  <p>Where</p>
  
  <p><code>id</code> - The auto increment value</p>
  
  <p><code>reff_id</code> - This is a unique string having this format XYZ#ddmmyyyy<code>id</code> (where id is the same rows id (the auto increment value) ) and XYZ is any random string having length 3</p>
  
  <p><code>pid</code> - which is the foreign key to a table called  <code>product</code></p>
  
  <p>I need a single Query to insert the value into the table and the query must insert <code>reff_id</code> dynamically with above logic .</p>
  
  <p>Any help appreciate . :) :) </p>
  
  <p>N.B</p>
  
  <p>I want a single query which is compute the value of <code>reff_id</code> at the time of insertion where the date format is represented the current date</p>