Re: On Duplicate Key Update question

2007-01-06 Thread ViSolve DB Team
Hi, From your query, understood that you want to retain old qty and new qty; result in another field. Try with, INSERT INTO TABLE1 (id,newqty) values (6,300) ON DUPLICATE KEY UPDATE totqty=oldqty+newqty, oldqty=newqty; Thanks, ViSolve DB Team - Original Message - From: "Ed Reed"

Re: On Duplicate Key Update question

2007-01-05 Thread Chris W
Ed Reed wrote: I use On Duplicate Key Update a lot and I usually use it like this, Insert Into tablename (myID, Qty) Values (1034,15), (6,13), (5001,1), (145,20) On Duplicate Key Update Qty=Values(Qty); This works very well but now I'd like to do something a little different. I'd like to have

Re: On Duplicate Key Update question

2007-01-05 Thread Ed Reed
Sorry for the premature question. I think I figured it out. On Duplicate Key Update Qty=Qty+Values(Qty); I haven't tested it yet but it makes sense that it'll work. >>> "Ed Reed" <[EMAIL PROTECTED]> 1/5/07 2:40 PM >>> I use On Duplicate Key Update a lot and I usually use it like this, Inser

Re: 'on duplicate key update' and 'last_insert_id'

2006-06-30 Thread David Hillman
On Jun 30, 2006, at 10:44 AM, Rob Desbois wrote: That leaves me with ON DUPLICATE KEY UPDATE. It's not amazingly helpful as you have to provide a column to update - however I can just say e.g. ON DUPLICATE KEY UPDATE id=id The problem with this is that if I then do "SELECT LAST_INSERT_ID

Re: On Duplicate Key....

2006-04-04 Thread Gabriel PREDA
Try: INSERT *IGNORE* INTO table (a,b) VALUES (1,2) -- Gabriel PREDA Senior Web Developer

Re: ON DUPLICATE KEY UPDATE and AUTO_INCREMENT columns

2005-05-20 Thread mfatene
Hi Sven, Last_insert_id is not what your're looking for, for the same reason you give about max(id) : your insert can find a duplicate key because another user inserted an id between two of yours. Last_insert_id gives just the last auto_increment id for success in insertion. Suppose that your inse

Re: ON DUPLICATE KEY UPDATE and AUTO_INCREMENT columns

2005-05-19 Thread Sven Paulus
On 19.05., [EMAIL PROTECTED] wrote: > If you add another command, > mysql> insert into bla1 values (NULL, "Cello3", NULL) on duplicate key update > whentime = NOW(); > The right ID will be used. Yes, if I insert an new value then the ID column gets incremented. But if I try to insert an existing v

Re: ON DUPLICATE KEY UPDATE and AUTO_INCREMENT columns

2005-05-19 Thread mfatene
Hi, If you add another command, mysql> insert into bla1 values (NULL, "Cello3", NULL) on duplicate key update whentime = NOW(); The right ID will be used. Since last_insert_id() has a connection scope, it's better for you to use : select max(id) from bla1; Mathias Selon Sven Paulus <[EMAIL P