incubator140 Posted December 9, 2009 Share Posted December 9, 2009 Hello All, Donno you have faced such a problem. But I had a struggling day as it was not working for me, but I am able to find something which is interesting. I have a table like this CREATE TABLE `abc` ( `a` int(11) UNSIGNED NOT NULL, `b` int(11) UNSIGNED NOT NULL, `c` varchar(50) NOT NULL, UNIQUE (`a`) ) ENGINE=MyISAM; And I am using the following query to insert a record or update if exist. INSERT INTO abc (a,b,c) VALUES (1,200, 'test') ON DUPLICATE KEY UPDATE c='test' unfortunately, that's not working. But the following is working well. (the difference is just the data type of field 'c') CREATE TABLE `abc` ( `a` int(11) UNSIGNED NOT NULL, `b` int(11) UNSIGNED NOT NULL, `c` int(50) NOT NULL, UNIQUE (`a`) ) ENGINE=MyISAM; INSERT INTO abc (a,b,c) VALUES (1,200, 300) ON DUPLICATE KEY UPDATE c=300 Can anyone tell me how to get rid of these problem ( I don't want to do it in two queries ) Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/184527-insert-intoon-duplicate-key-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.