现在有一个表CREATE TABLE `package` (
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '物品ID',
`count` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '数量',
`lcateg` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '大类别',
`scateg` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '小类别',
PRIMARY KEY (`uid`,`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8我想在插入数据的时候,如果有已存在的uid,pid相同的数据,则更新,没有相同的再插入,可不可以用一条SQL语句搞定?
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '物品ID',
`count` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '数量',
`lcateg` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '大类别',
`scateg` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '小类别',
PRIMARY KEY (`uid`,`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8我想在插入数据的时候,如果有已存在的uid,pid相同的数据,则更新,没有相同的再插入,可不可以用一条SQL语句搞定?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货