Heim >Datenbank >MySQL-Tutorial >MySQL update select,update的同时select和for update语句_MySQL

MySQL update select,update的同时select和for update语句_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:35:191364Durchsuche

bitsCN.com

MySQL update select,update的同时select和for update语句

 

MySQL update && select

 

CREATE TABLE `testupdate` (

  `id` bigint(20) NOT NULL AUTO_INCREMENT,

  `val` bigint(20) NOT NULL DEFAULT '0',

  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8

 

update testupdate

 

set val = val+1

 

where id = 1 and @value := val+1;

 

select @value;

bitsCN.com
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn