Gary Smith wrote:
Steve Edberg wrote:
(2) autoincrement values are not reused after deletion, so if you
deleted the record with ID=1000 inserted in (1), the next
autoincrement would still be 1001, even if the existing records are
IDs 1,2,3. This is usually the desired behavior, but again, may
Gary Smith skrev:
...
An example of where it wouldn't be: Although ID is auto_increment, you
could define a row as, say, '10005583429'. This would be a valid input.
Selecting max(id) would return that number. However, auto_increment
wouldn't change - it would still be '34' (or whatever) for t
Steve Edberg wrote:
(2) autoincrement values are not reused after deletion, so if you
deleted the record with ID=1000 inserted in (1), the next
autoincrement would still be 1001, even if the existing records are
IDs 1,2,3. This is usually the desired behavior, but again, may not be
what *you*
On Sun, Dec 27, 2009 at 1:30 PM, Gary Smith wrote:
> Victor Subervi wrote:
>
>> On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman
>> wrote:
>>
>>
>>
>>> last_insert_id() returns the last id auto-incremented in *the current
>>> session*. If you disconnect and reconnect, it can not be retrieved.
>
At 11:13 AM -0500 12/27/09, you wrote:
Hi;
mysql> select * from products;
++--+--+---++-+---++--++-+--+---+--+---+---++-
Victor Subervi wrote:
On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman wrote:
last_insert_id() returns the last id auto-incremented in *the current
session*. If you disconnect and reconnect, it can not be retrieved.
Ahah! So how do I retrieve the last id inserted irrespective of co
On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman wrote:
> last_insert_id() returns the last id auto-incremented in *the current
> session*. If you disconnect and reconnect, it can not be retrieved.
>
Ahah! So how do I retrieve the last id inserted irrespective of connection?
TIA,
V
last_insert_id() returns the last id auto-incremented in *the current
session*. If you disconnect and reconnect, it can not be retrieved.
- michael dykman
On Sun, Dec 27, 2009 at 11:42 AM, Victor Subervi
wrote:
> On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi wrote:
>
>> 2009/12/27 Victor Sub
On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi wrote:
> 2009/12/27 Victor Subervi :
> > mysql> select * from products;
> [...]
> > mysql> select last_insert_id() from products;
> [...]
> > Now, I was expecting 1, not 0! What up?
>
> [...] LAST_INSERT_ID() (no arguments) returns the first
> automat
2009/12/27 Victor Subervi :
> mysql> select * from products;
[...]
> mysql> select last_insert_id() from products;
[...]
> Now, I was expecting 1, not 0! What up?
[...] LAST_INSERT_ID() (no arguments) returns the first
automatically generated value successfully inserted for
an AUTO_INCREMENT colum
Thank you very much for all answers
I will trying Triggers and the example with the update after an INSERT.
Ant then, I use the best for me;-)
Thunder
Yes, Triggers... I so rarely use them I forget they exist.
On Tue, May 5, 2009 at 10:22 AM, Thomas Pundt wrote:
Johnny Withers schr
Yes, Triggers... I so rarely use them I forget they exist.
On Tue, May 5, 2009 at 10:22 AM, Thomas Pundt wrote:
> Johnny Withers schrieb:
>
>> Well, I think an update after insert is the only way. Other than
>> perpopulating another table with possibe crc values then usinga join:
>>
>> Select id
Johnny Withers schrieb:
Well, I think an update after insert is the only way. Other than
perpopulating another table with possibe crc values then usinga join:
Select id from testtable
Inner join crctable on testtable.id=crctable.id
Where crctable.crcval='xxx'
Just be sure to index the crcva
Well, I think an update after insert is the only way. Other than
perpopulating another table with possibe crc values then usinga join:
Select id from testtable
Inner join crctable on testtable.id=crctable.id
Where crctable.crcval='xxx'
Just be sure to index the crcval column.
On Sunday, Ma
I'm so sorry for the mistake...
I mean:
I think it is to slow when I make a SELECT later in this form:
I don't think its possible to do what you want in a single statement. Since
LAST_INSERT_ID() is set to the last insert id of the connection... and the
row you are inserting doesn't exist.. wel
Hi Johnny,
I need the CRC32 for a unique URL-ID...
I think it isn't to slow when I make a SELECT later in this form:
Rows in Table: 825,984
Search for id: 2532552 (CRC32: 46316330)
SELECT id FROM `testtable` WHERE id = "2532552"
0.0005 sec.
SELECT id FROM `testtable` WHERE CRC32(id) = "46316
I don't think its possible to do what you want in a single statement. Since
LAST_INSERT_ID() is set to the last insert id of the connection... and the
row you are inserting doesn't exist.. well.. until you create it, it will
always either be zero or the record BEFORE your next insert, ie:
INSERT I
Afshad Dinshaw wrote:
Hi
Im using the latest version of mysql.
When I run the following query :
select last_insert_id()
if get the error message:
function vcontacts.last_insert_id does not exist
note: vcontacts is the name of my database.
anyone know why?
thanks
I can run it both upperca
me
advice...
From: Philippe Poelvoorde <[EMAIL PROTECTED]>
Reply-To: "'mysql@lists.mysql.com '"
To: mel list_php <[EMAIL PROTECTED]>
CC: mysql@lists.mysql.com
Subject: Re: last_insert_id
Date: Tue, 15 Feb 2005 10:50:40 +
mel list_php wrote:
Hi!
I have a database whe
ply-To: "'mysql@lists.mysql.com '"
To: mel list_php <[EMAIL PROTECTED]>
CC: mysql@lists.mysql.com
Subject: Re: last_insert_id
Date: Tue, 15 Feb 2005 10:50:40 +
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have my
'"
To: mel list_php <[EMAIL PROTECTED]>
CC: mysql@lists.mysql.com
Subject: Re: last_insert_id
Date: Tue, 15 Feb 2005 10:50:40 +
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have my insert queries as atomic, but I was wonderin
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have my insert queries as atomic, but I was wondering about
one special case: I make one insert, and retrieve the last id inserted
by mysql because I need to update an other table with that id.
"mel list_php" <[EMAIL PROTECTED]> wrote on 15/02/2005 10:18:55:
> Hi!
>
> I have a database where several users can connect and input data.
>
> I managed to have my insert queries as atomic, but I was wondering about
one
> special case: I make one insert, and retrieve the last id inserted by
Hi,
You can probably use "SELECT LAST_INSERT_ID()" which keeps
auto-increment values on a per connection basis.
See:
http://dev.mysql.com/doc/mysql/en/getting-unique-id.html
/Johan
mel list_php wrote:
Hi!
I have a database where several users can connect and input data.
I managed to have my insert
Hello.
As said at:
http://dev.mysql.com/doc/mysql/en/Information_functions.html
"If you insert many rows at the same time with an insert statement,
LAST_INSERT_ID() returns the value for the first inserted row."
LOAD DATA INFILE inserts several rows a time, so this is a usual
behavio
"paqogomez" <[EMAIL PROTECTED]> wrote:
> I am trying to build a stored procedure in v. 5.
> This is what I have so far.
>
> delimiter |
> create procedure get_id(out oid int)
> begin
>insert into mercury.merchant (name) values(null);
>select last_insert_id() into @mid;
>insert into mer
Oh.
If only I'd tried ONE more thing before mailing that out!
If anyone does have the same problem, the vital (missing) piece of
information is that I was using MySQLCC. It seems to have problems with SPs
unless you open a new query window after changing the contents of a
procedure..
Thanks,
M
Don't forget that if you "commit" then last_insert_id will return 0
- Original Message -
From: "William R. Mussatto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 24, 2003 6:56 PM
Subject: Re: last_insert_id()
: R.Dobson sa
R.Dobson said:
> Hi,
>
> Is it possible to obtain the last_insert_id() for a particular column in
> a particular table?
> eg, say i wanted to obtain the last insert id of a column called id in
> table reference, something along the lines of:
>
> last_insert_id(reference.id)
>
> The reason I ask is
At 16:02 +0300 6/17/03, Baris Akin wrote:
Hello,
I try to get last inserted autoincrement record ID on table with
LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
connection returns it's own last inserted ID not actual ID. Is this a
bug? Also it returns more than one record
"Baris Akin" <[EMAIL PROTECTED]> wrote:
> LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
> connection returns it's own last inserted ID not actual ID. Is this a
> bug?
No. LAST_INSERT_ID() works per-connection. It returns the last inserted auto_increment
value from current
On Tue, Jun 17, 2003 at 04:02:46PM +0300, Baris Akin wrote:
> I try to get last inserted autoincrement record ID on table with
> LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every
> connection returns it's own last inserted ID not actual ID. Is this a
> bug? Also it returns more
Could it be that the table types are different?
the innodb table types seem to ignore auto_increment
while MyISAM are more accommodating... so it might be
that your table on Linux is MyISAM type while the
table on XP is Innodb type.
--- Alan <[EMAIL PROTECTED]> wrote:
> Okay, I've seen just a
In the last episode (Feb 01), Alan said:
> Okay, I've seen just about every question on last_insert_id(), except
> this one:
>
> I am running MySQL on Win XP and when I generate a test table (test)
> with an AUTO_INCREMENT column (aid) and a second column (a) then use
> an insert statement like: I
This looks like the same problem I have with MS Access. It seems MS Access
uses the SELECT id FROM table_name WHERE is IS NULL, and this syntax clears
the last insert ID field. My solution is here:
--- One Line URL, might wrap ---
http://groups.google.com/groups?hl=en&safe=off&threadm=9ehc8i%2
The .Neta Adapter.. does it make a persistent connection?
If the connection drops between the first insert and the call to select,
then the return would be zero
Alan
> -Original Message-
> From: Cain O'Sullivan [mailto:cos@;iinet.net.au]
> Sent: Wednesday, 13 November 2002 16:13
> To: [EM
Hi Sean,
> "If expr is given as an arguement to LAST_INSERT_ID(), the value of the
> arguement is returned by the function, is set as the next value to be
> returned by LAST_INSERT_ID(), and is used as the next AUTO_INCREMENT
> value"
I don't think this entire statement is correct. The onlin
At 1:49 -0700 9/20/02, PR wrote:
>I have a message board app I'm using where I'm trying to make the code
>faster and more efficient than it is now. At times this board will
>generate a lot of new posts to it very very quickly. In one section where
>posts are added, after the post is made and ins
Don't include a from clause with the last_insert_id(), or you will get
a full table scan.
The last_insert_id will only give you the insert id for the last record
inserted.
mysql mailing list user wrote:
> Hi,
> I have a big problem with last_insert_id() query.
> I am adding records to a tabl
On Tuesday, April 23, 2002, at 03:10 PM, destr0 wrote:
> SELECT LAST_INSERT_ID() as id FROM myTable;
>
> It returns the last inserted Id, but why does it return that value for
> every
> row in the table.
>
> for example.
> if there are 5 total records in the table. and the last inserted Id is
At 02:10 PM 4/23/2002, you wrote:
>query, table
>
>When I run the query:
>
>SELECT LAST_INSERT_ID() as id FROM myTable;
>
>It returns the last inserted Id, but why does it return that value for every
>row in the table.
>
>for example.
>if there are 5 total records in the table. and the last insert
On Tuesday 23 April 2002 1:10 pm, destr0 wrote:
> query, table
>
> When I run the query:
>
> SELECT LAST_INSERT_ID() as id FROM myTable;
This query really makes no sense. It is almost the same as:
SELECT LAST_INSERT_ID() as id;
> It returns the last inserted Id, but why does it return that val
Hi Paul
On Monday 08 April 2002 12:56 am, Paul DuBois wrote:
> You're inserting a specific value into the AUTO_INCREMENT field, which
> doesn't result in the creation of a new automatic sequence number.
>
> If you want to insert a record with a specific value in that column, *and*
> you want the
>On Sun, 7 Apr 2002 19:56:47 -0500
>Paul DuBois <[EMAIL PROTECTED]> wrote:
>
>> >I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table
>> >"customers" with an auto-incrementing primary key "customer_id".
>>If I insert
>> >a record:
>> >mysql> insert into customers(custome
On Sun, 7 Apr 2002 19:56:47 -0500
Paul DuBois <[EMAIL PROTECTED]> wrote:
> >I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table
> >"customers" with an auto-incrementing primary key "customer_id". If I insert
> >a record:
> >mysql> insert into customers(customer_id) values
>I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table
>"customers" with an auto-incrementing primary key "customer_id". If I insert
>a record:
>mysql> insert into customers(customer_id) values ("10");
>and then ask for the last insert:
>mysql> select last_insert_id();
>(whic
> I am doing this using mySQlGui 1.7.5-2 on Win 2000
> Professional.
>From what I understand last_insert_id() can only be used
on the same connection as the insert. I'm guessing after every query
mysqlgui runs it disconnects, therefore killing last_insert_id().
-Jason Yates
---
On Tue, 02 Oct 2001 14:37, Paul DuBois wrote:
> At 10:45 AM +1200 10/2/01, marcus davy wrote:
> >On Mon, 01 Oct 2001 14:44, Paul DuBois wrote:
> >> At 11:44 AM +1200 10/1/01, marcus davy wrote:
> >> >If you specify the keyword IGNORE in an INSERT, any rows that
> >> > duplicate an existing PRIM
At 10:45 AM +1200 10/2/01, marcus davy wrote:
>On Mon, 01 Oct 2001 14:44, Paul DuBois wrote:
>> At 11:44 AM +1200 10/1/01, marcus davy wrote:
>> >If you specify the keyword IGNORE in an INSERT, any rows that duplicate
>> >an existing PRIMARY or UNIQUE key in the table are ignored and are not
>>
On Mon, 01 Oct 2001 14:44, Paul DuBois wrote:
> At 11:44 AM +1200 10/1/01, marcus davy wrote:
> >If you specify the keyword IGNORE in an INSERT, any rows that duplicate
> >an existing PRIMARY or UNIQUE key in the table are ignored and are not
> >inserted.
> >But the last_insert_id() function still
ere the last record
violates a unique key and therefore has to be ignored, and if one
wants to use that last value - although that a rather special case.
Bye,
Benjamin.
>
> Will French
>
> > -Original Message-
> > From: Paul DuBois [mailto:[EMA
-Original Message-
> From: Paul DuBois [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 30, 2001 10:45 PM
> To: marcus davy; [EMAIL PROTECTED]
> Subject: Re: last_insert_id() bug ?? using INSERT IGNORE
>
>
> At 11:44 AM +1200 10/1/01, marcus davy wrote:
> >
At 11:44 AM +1200 10/1/01, marcus davy wrote:
>If you specify the keyword IGNORE in an INSERT, any rows that duplicate
>an existing PRIMARY or UNIQUE key in the table are ignored and are not
>inserted.
>But the last_insert_id() function still appears to increment by one
>in situations when the que
Curtis Maurand schrieb am Mittwoch, 22. August 2001, 21:17:40:
> A caveat is that you get the last_insert_id for your connection. Not the
> last one in the database.
I'm puzzled. There is no last_insert_id of the database, only of
a certain table, and it is indeed the one last manipulated. S
A caveat is that you get the last_insert_id for your connection. Not the
last one in the database.
Curtis
On Wed, 22 Aug 2001, Dr. Werner Stürenburg wrote:
>
>
> Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 14:57:06:
>
> > At 13:19 22.8.2001 +0200, you wrote:
> >>LAST_INSERT_ID() should
Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 14:57:06:
> At 13:19 22.8.2001 +0200, you wrote:
>>LAST_INSERT_ID() should return the last autoincrement value of
>>the last insert
> Yep it sure did, managed to get to machine and test it out. Total mess.
> but;
> $query = "SELECT LAST_INSER
At 13:19 22.8.2001 +0200, you wrote:
>LAST_INSERT_ID() should return the last autoincrement value of
>the last insert
Yep it sure did, managed to get to machine and test it out. Total mess.
but;
$query = "SELECT LAST_INSERT_ID()";
$result = mysql_query($query);
if ($result) {
$nrows = mysql_num
Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 11:31:01:
> Hi,
> in the manual there is this LAST_INSERT_ID() and it is what I actually need
> but there is some confusion over how to use it in many tables.
> http://www.mysql.com/doc/O/D/ODBC_and_last_insert_id.html>
> Or, if you are just
On Tue, Jun 12, 2001 at 04:47:47PM -0500, Paul DuBois wrote:
>
> Try using:
>
> $dbh->do ("UPDATE ... WHERE k = ?", undef, "xxx")
> and then access $dbh->{mysql_insertid} to see if you get a different
> result. I suspect perhaps not, but it's something to try.
Unfortunately I get the same resu
At 4:34 PM -0500 6/12/01, Erik Rantapaa wrote:
>This really might be a DBI problem, but I find it's pretty weird.
>
>I am attempting to perform atomic updates by using UPDATE statements
>like:
>
> UPDATE counter SET v = last_insert_id(v+1) WHERE k = 'xxx';
>
>where counter has the schema: cr
; [EMAIL PROTECTED]
Subject: Re: LAST_INSERT_ID Issues
At 9:48 AM -0400 5/25/01, Dave Carter wrote:
>This does not return any results
>
>SELECT LAST_INSERT_ID() FROM tablename;
It doesn't return *any* results? Or do you mean it returns 0?
FROM tablename is superfluous here; t
query
>
>-Original Message-
>From: Billy Passauer [mailto:[EMAIL PROTECTED]]
>Sent: Friday, May 25, 2001 10:18 AM
>To: Dave Carter
>Subject: RE: LAST_INSERT_ID Issues
>
>
>> -Original Message-
>> From: Dave Carter [mailto:[EMAIL PROTECTED]]
>&
At 9:48 AM -0400 5/25/01, Dave Carter wrote:
>This does not return any results
>
>SELECT LAST_INSERT_ID() FROM tablename;
It doesn't return *any* results? Or do you mean it returns 0?
FROM tablename is superfluous here; the most recent AUTO_INCREMENT value
is maintained on a per-connection basi
://www.abti.cc
717.464.2970
Filter Lovin: sql, database, query
-Original Message-
From: Billy Passauer [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 25, 2001 10:18 AM
To: Dave Carter
Subject: RE: LAST_INSERT_ID Issues
> -Original Message-
> From: Dave Carter [mailto:[EMAIL PRO
Hello Dave,
If your auto-incrementing field in your table are Account_ID for exemple,
try :
Select Account_ID From tablename Where Account_ID = LAST_INSERT_ID();
This work fine for me
Bye
Ghislain Proulx
Web Programmer
Groupe Ordimax
http://www.ordimax.com
http://www.infoteck.qc.ca
> -O
So sprach Graeme B. Davis am Tue, May 01, 2001 at 01:09:15PM -0400:
> Ok I was thinking that you had to tell LAST_INSERT_ID the table you wanted
> to get the last insert id from. What if you run a web site and you have 10
> tables in a database, how can you tell what the last insert id of table 6
> COk I was thinking that you had to tell LAST_INSERT_ID the table you
wanted
> to get the last insert id from. What if you run a web site and you have
10
> tables in a database, how can you tell what the last insert id of table 6
> was?
As I understand it, LAST_INSERT_ID is connection based, n
Ok now I understand -- it's on a per-connection basis =)
thanks,
graeme
- Original Message -
From: "Graeme B. Davis" <[EMAIL PROTECTED]>
To: "Gerald Clark" <[EMAIL PROTECTED]>; "Braxton Robbason"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PRO
Ok I was thinking that you had to tell LAST_INSERT_ID the table you wanted
to get the last insert id from. What if you run a web site and you have 10
tables in a database, how can you tell what the last insert id of table 6
was?
Thanks,
Graeme
> Because you included a from clause, you got one
Because you included a from clause, you got one line for each row
of 'outages'
Leave out the "from outages"
Graeme B. Davis wrote:
> mysql> INSERT INTO outages (status) VALUES ('Open');
> mysql> SELECT LAST_INSERT_ID() AS lid FROM outages;
> +-+
> | lid |
> +-+
> | 101 |
> | 101 |
> | 1
last_insert_id is a function. It will return a value for each row in the
table. You want to run:
select last_insert_id() as lid;
instead of selecting from a table.
-Original Message-
From: Graeme B. Davis [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 30, 2001 3:17 PM
To: [EMAIL PROTECT
On Sat, Mar 31, 2001 at 10:11:33PM +0530, P.V. Sajan wrote:
> Helllo All !!
>
> I 've a problem i want to retrieve the primary key value of the last
> Inserted record in a table and use it in another table.
>
> I did
> select Last_Insert_Id () from trans ;
What you were doing is like:
select 1
72 matches
Mail list logo