语法
UPDATE table_name
SET field1 = new_value1,field2 = new_value2,...
[WHERE Clause]
例子
//结构
CREATE TABLE `user` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(10) NOT NULL,
`sex` tinyint(4) NOT NULL,
`tel` char(11) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
//更新单个字段
UPDATE `user` SET `tel`='13800138010' WHERE `id`='1';
//更新多个字段
UPDATE `user` SET `tel`='13800138010',`name`='李明' WHERE `id`='1';
网友评论