Need some assistance in this query. I was doing 3 queries to perform what i just found out can be done with 1. But it keeps adding a new record instead of updating..
INSERT INTO vendors (vendor, name, tel, email, popularity) VALUES
('ibm','support','911','ibm@ibm.com','0') ON DUPLICATE KEY UPDATE
vendor='ibm', name = 'support', tel = '911',email = 'ibm@ibm.com',
popularity = popularity+1
I have the 'id' column set as unique... Schema below.
CREATE TABLE `vendors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`vendor` text NOT NULL,
`name` text NOT NULL,
`tel` text NOT NULL,
`email` text NOT NULL,
`popularity` int(11) DEFAULT NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1;
This is new for me but i have checked the syntax on the mysql site.. Can't see the problem.
Thanks