Databases :: MySql :: problem in max select max(Company_ID) |
|||
| By: preeth |
Date: 22/09/2004 00:00:00 |
Points: 125 | Status: Answered Quality : Excellent |
|
Hi to all EEE I have a table with an auto_increment field. Is there a quick way to find out what the value of the auto_increment field of the last row in the table is? --- I have tried this strsql = "select max(Company_ID) from company" rs1.open strsql,con its giving error as.. ADODB.Fields error '800a0cc1' ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application. /kingfisher/addcompany2.asp, line 28 the line 28 is <%=rs1("Company_ID")%> Thx in advance Preet |
|||
| By: VGR | Date: 22/09/2004 18:28:00 | Type : Answer |
|
| of course, because the returned column is named "max(Company_ID)", not "Company_ID" :D :D :D use this technique : strsql = "select max(Company_ID) as a from company" and in the line 28 <%=rs1("a")%> you've also other techniques, but that one will do the job. |
|||
| By: preeth | Date: 22/09/2004 18:42:00 | Type : Comment |
|
| Thx VGR, full points |
|||
| By: preeth | Date: 22/09/2004 18:44:00 | Type : Comment |
|
| Can u pls tell me the other Tech, along difference between this two |
|||
| By: VGR | Date: 22/09/2004 18:53:00 | Type : Comment |
|
| the other one is related to the situation in which you usually NEED the value of the last auto_incremented ID. this situation is when you just uinserted a new line :D Thus the other technique involves trusting those : either query MySql the usual way : mysql> SELECT LAST_INSERT_ID(); <A HREF="http://www.mysql.com/doc/en/Miscellaneous_functions.html">http://www.mysql.com/doc/en/Miscellaneous_functions.html</A> or query fromPHP via this wrapper : mysql_insert_id -- Get the ID generated from the previous INSERT operation <A HREF="http://www.php.net/manual/en/function.mysql-insert-id.php">http://www.php.net/manual/en/function.mysql-insert-id.php</A> regards |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








