ON DUPLICATE KEY UPDATE and AUTOINCREMENT columns. I thought this might be possible using INSERT. ON DUPLICATE KEY UPDATE., but LASTINSERTID seems to be unusable in this case. Nintendo switch master key generator 11.2. But of course the MySQL manual says 'The value of LASTINSERTID is not changed if you update the AUTOINCREMENT column of a row with a non-magic.
- Mysql On Duplicate Key Update Changes Auto Generated Id Number
- Mysql On Duplicate Key Update Changes Auto Generated Id Form
Insert into t1 (a,b,c) values (1,2,3) on duplicate key update c=3; insert into t1 (a,b,c) values (4,5,6) on duplicate key update c=9; Note The use of VALUES to refer to the new row and columns is deprecated beginning with MySQL 8.0.20, and is subject to removal in a future version of MySQL. Oct 05, 2012 The propel-gen diff task generates wrong SQL for MySQL when a primary key changes. For example if we have a table (id, cola, colb) and the primary key is currently on id and the new primary key is on (cola, colb) then the generated S.
Posted by: Jakub Wisniewski
Date: August 22, 2007 01:45PM
Hello,
One of my clients has just mailed me about a bug which has occurred in an application I wrote some time ago.
After some tracking I finally got to the table:
> CREATE TABLE `devel_travel_miasta` (
> `id_town` int(10) unsigned NOT NULL auto_increment,
> `name` varchar(64) collate utf8_polish_ci NOT NULL,
> `confirmed` tinyint(1) unsigned NOT NULL default '0',
> PRIMARY KEY (`id_town`),
> UNIQUE KEY `unique` (`name`)
> ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=1065;
and the query
> INSERT INTO '.TAB_TRAVEL_MIASTA.' (name) VALUES ('.$name.') ON DUPLICATE KEY UPDATE name = '.$name.';
which on the 5.0.45-log server after invoking mysql_insert_id(); returns 'next autoindex' value instead of the ID value of the updated row.
The code used to work fine till today on the remote (probably just upgraded) server, and works fine on my local 5.0.27-community-nt server.
Any clue what's going on?
Regards,
Jakub Wiśniewski
Custom Internet Solutions
http://jrobin.net/en
Options:Reply•Quote
Views
Posted
5648
August 22, 2007 01:45PM
2567
September 02, 2007 01:16PM
Sorry, you can't reply to this topic. It has been closed.
Mysql On Duplicate Key Update Changes Auto Generated Id Number
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.
Posted by: Anatoliy V
Date: September 10, 2008 11:02AM
Hi, all!
Help me please!
How can i correct implements this queries:
insert into test.counter ( id, max_users_id ) values ( 1, MAX(users.id) ) on DUPLICATE KEY UPDATE max_users_id = MAX(users.id);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1, MAX(users.id) ) on DUPLICATE KEY UPDATE max_users_id = MAX(users.id)' at line 1
Thanks!
Options:Reply•Quote
Written By
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.