<div>Hi David</div>
<div>I did that, but the auto-increment field values starts from a high integer value (approx 15594). Then onwards for each row it is incremented by 1.</div>
<div>Though I do not see any problem with that (starting from high value), I would have liked the value to start from 0 or 1 and keep incrementing for each row.<br></div>
<div>Is there any-way, I can force the value to start from 0 or 1.</div>
<div> </div>
<div>Best Regards</div>
<div>Austin<br></div>
<div class="gmail_quote">On Mon, Mar 28, 2011 at 11:42 PM, Metzler, David <span dir="ltr">&lt;<a href="mailto:metzlerd@evergreen.edu">metzlerd@evergreen.edu</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>Do not include cid in the insert statement and it should autoincrement for you.<br>
<div>
<div></div>
<div class="h5"><br>-----Original Message-----<br>From: <a href="mailto:support-bounces@drupal.org">support-bounces@drupal.org</a> on behalf of Austin Einter<br>Sent: Mon 3/28/2011 03:04<br>To: <a href="mailto:support@drupal.org">support@drupal.org</a>; <a href="mailto:development@drupal.org">development@drupal.org</a><br>
Subject: [support] How to get the auto-increment value<br><br>Hi All<br>I have a table, where &#39;cid&#39; field is of type &quot;serial&quot;.<br><br>Schema declaration is -&gt;  *&quot;&#39;cid&#39; =&gt; array(&#39;type&#39; =&gt; &#39;serial&#39;, &#39;unsigned&#39; =&gt;<br>
TRUE, &#39;not null&#39; =&gt; TRUE, ),&quot;*<br><br>Aim is to have an incremented value for it.<br>The code is as below<br><br>*$lastid = 0;<br> for($delta = 0; $delta &lt; $all_companies; $delta++)<br> {<br> $lastid = db_last_insert_id(rs_companies, cid) + 1;<br>
     db_query(<br>   &#39;INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate,<br>releasedate) &#39;<br>     .&quot;VALUES (%d, &#39;%d&#39;, &#39;%s&#39;, &#39;%d&#39;, &#39;%d&#39;)&quot;,<br> $lastid,  *<br><br>
With this, I find this &#39;cid&#39; field is not auto incrementing.  Any idea,<br>whats the wrong here.<br><br>Best Regards<br>Austin.<br><br></div></div><br>--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</blockquote></div><br>