mysql update unique index

Posted by atno on Stack Overflow See other posts from Stack Overflow or by atno
Published on 2011-01-08T02:38:19Z Indexed on 2011/01/09 3:54 UTC
Read the original article Hit count: 205

Filed under:

Is there a way to say UPDATE items SET qty=10 WHERE **unique key** instead of saying UPDATE items SET qty=10 WHERE userID=1 AND listID=10 and itemID=100 on the following table?

CREATE TABLE IF NOT EXISTS `items` (
  `userID` int(20) NOT NULL,
  `listID` int(20) NOT NULL,
  `itemID` int(20) NOT NULL,
  `qty` int(10) NOT NULL,
  UNIQUE KEY `unique` (`userID`,`listID`,`itemID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

© Stack Overflow or respective owner

Related posts about mysql-query